| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2012 by Oracle Inc |
|---|
| 3 | 4 | * Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> |
|---|
| .. | .. |
|---|
| 5 | 6 | * This code borrows ideas from https://lkml.org/lkml/2011/11/30/249 |
|---|
| 6 | 7 | * so many thanks go to Kevin Tian <kevin.tian@intel.com> |
|---|
| 7 | 8 | * and Yu Ke <ke.yu@intel.com>. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 10 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 11 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 14 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 15 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 16 | | - * more details. |
|---|
| 17 | | - * |
|---|
| 18 | 9 | */ |
|---|
| 19 | 10 | |
|---|
| 20 | 11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 410 | 401 | /* All online CPUs have been processed at this stage. Now verify |
|---|
| 411 | 402 | * whether in fact "online CPUs" == physical CPUs. |
|---|
| 412 | 403 | */ |
|---|
| 413 | | - acpi_id_present = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL); |
|---|
| 404 | + acpi_id_present = bitmap_zalloc(nr_acpi_bits, GFP_KERNEL); |
|---|
| 414 | 405 | if (!acpi_id_present) |
|---|
| 415 | 406 | return -ENOMEM; |
|---|
| 416 | 407 | |
|---|
| 417 | | - acpi_id_cst_present = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL); |
|---|
| 408 | + acpi_id_cst_present = bitmap_zalloc(nr_acpi_bits, GFP_KERNEL); |
|---|
| 418 | 409 | if (!acpi_id_cst_present) { |
|---|
| 419 | | - kfree(acpi_id_present); |
|---|
| 410 | + bitmap_free(acpi_id_present); |
|---|
| 420 | 411 | return -ENOMEM; |
|---|
| 421 | 412 | } |
|---|
| 422 | 413 | |
|---|
| 423 | 414 | acpi_psd = kcalloc(nr_acpi_bits, sizeof(struct acpi_psd_package), |
|---|
| 424 | 415 | GFP_KERNEL); |
|---|
| 425 | 416 | if (!acpi_psd) { |
|---|
| 426 | | - kfree(acpi_id_present); |
|---|
| 427 | | - kfree(acpi_id_cst_present); |
|---|
| 417 | + bitmap_free(acpi_id_present); |
|---|
| 418 | + bitmap_free(acpi_id_cst_present); |
|---|
| 428 | 419 | return -ENOMEM; |
|---|
| 429 | 420 | } |
|---|
| 430 | 421 | |
|---|
| .. | .. |
|---|
| 533 | 524 | return -ENODEV; |
|---|
| 534 | 525 | |
|---|
| 535 | 526 | nr_acpi_bits = get_max_acpi_id() + 1; |
|---|
| 536 | | - acpi_ids_done = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL); |
|---|
| 527 | + acpi_ids_done = bitmap_zalloc(nr_acpi_bits, GFP_KERNEL); |
|---|
| 537 | 528 | if (!acpi_ids_done) |
|---|
| 538 | 529 | return -ENOMEM; |
|---|
| 539 | 530 | |
|---|
| 540 | 531 | acpi_perf_data = alloc_percpu(struct acpi_processor_performance); |
|---|
| 541 | 532 | if (!acpi_perf_data) { |
|---|
| 542 | 533 | pr_debug("Memory allocation error for acpi_perf_data\n"); |
|---|
| 543 | | - kfree(acpi_ids_done); |
|---|
| 534 | + bitmap_free(acpi_ids_done); |
|---|
| 544 | 535 | return -ENOMEM; |
|---|
| 545 | 536 | } |
|---|
| 546 | 537 | for_each_possible_cpu(i) { |
|---|
| .. | .. |
|---|
| 584 | 575 | err_out: |
|---|
| 585 | 576 | /* Freeing a NULL pointer is OK: alloc_percpu zeroes. */ |
|---|
| 586 | 577 | free_acpi_perf_data(); |
|---|
| 587 | | - kfree(acpi_ids_done); |
|---|
| 578 | + bitmap_free(acpi_ids_done); |
|---|
| 588 | 579 | return rc; |
|---|
| 589 | 580 | } |
|---|
| 590 | 581 | static void __exit xen_acpi_processor_exit(void) |
|---|
| .. | .. |
|---|
| 592 | 583 | int i; |
|---|
| 593 | 584 | |
|---|
| 594 | 585 | unregister_syscore_ops(&xap_syscore_ops); |
|---|
| 595 | | - kfree(acpi_ids_done); |
|---|
| 596 | | - kfree(acpi_id_present); |
|---|
| 597 | | - kfree(acpi_id_cst_present); |
|---|
| 586 | + bitmap_free(acpi_ids_done); |
|---|
| 587 | + bitmap_free(acpi_id_present); |
|---|
| 588 | + bitmap_free(acpi_id_cst_present); |
|---|
| 598 | 589 | kfree(acpi_psd); |
|---|
| 599 | 590 | for_each_possible_cpu(i) |
|---|
| 600 | 591 | acpi_processor_unregister_performance(i); |
|---|