Skip to content

Commit

Permalink
ACPI: sysfs: Unify pattern of memory allocations
Browse files Browse the repository at this point in the history
Use the form of foo = kmalloc(sizeof(*foo)) everywhere in order to
unify pattern of memory allocations.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Andy Shevchenko authored and Rafael J. Wysocki committed Jun 17, 2021
1 parent d3121e6 commit b272c05
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/acpi/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@ acpi_status acpi_sysfs_table_handler(u32 event, void *table, void *context)

switch (event) {
case ACPI_TABLE_EVENT_INSTALL:
table_attr =
kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
table_attr = kzalloc(sizeof(*table_attr), GFP_KERNEL);
if (!table_attr)
return AE_NO_MEMORY;

Expand Down Expand Up @@ -842,22 +841,19 @@ void acpi_irq_stats_init(void)
num_gpes = acpi_current_gpe_count;
num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA;

all_attrs = kcalloc(num_counters + 1, sizeof(struct attribute *),
GFP_KERNEL);
all_attrs = kcalloc(num_counters + 1, sizeof(*all_attrs), GFP_KERNEL);
if (all_attrs == NULL)
return;

all_counters = kcalloc(num_counters, sizeof(struct event_counter),
GFP_KERNEL);
all_counters = kcalloc(num_counters, sizeof(*all_counters), GFP_KERNEL);
if (all_counters == NULL)
goto fail;

status = acpi_install_global_event_handler(acpi_global_event_handler, NULL);
if (ACPI_FAILURE(status))
goto fail;

counter_attrs = kcalloc(num_counters, sizeof(struct kobj_attribute),
GFP_KERNEL);
counter_attrs = kcalloc(num_counters, sizeof(*counter_attrs), GFP_KERNEL);
if (counter_attrs == NULL)
goto fail;

Expand Down

0 comments on commit b272c05

Please sign in to comment.