From cd27f56fce4fedc975663ecebb8166444a80b75c Mon Sep 17 00:00:00 2001 From: Kimberly Brown Date: Thu, 25 Oct 2018 20:04:55 -0400 Subject: [PATCH] staging: gasket: use sizeof(*p) for memory allocation Use sizeof(*p) instead of sizeof(struct P) for memory allocation. This change complies with the Linux kernel coding style. It improves readability and decreases the opportunity for bugs if the pointer variable type is changed. Issue found by checkpatch. Signed-off-by: Kimberly Brown Acked-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 17 ++++++++--------- drivers/staging/gasket/gasket_page_table.c | 3 ++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 49d47afad64f..ad5657d213f0 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -184,7 +184,7 @@ gasket_interrupt_msix_init(struct gasket_interrupt_data *interrupt_data) interrupt_data->msix_entries = kcalloc(interrupt_data->num_interrupts, - sizeof(struct msix_entry), GFP_KERNEL); + sizeof(*interrupt_data->msix_entries), GFP_KERNEL); if (!interrupt_data->msix_entries) return -ENOMEM; @@ -322,8 +322,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev) const struct gasket_driver_desc *driver_desc = gasket_get_driver_desc(gasket_dev); - interrupt_data = kzalloc(sizeof(struct gasket_interrupt_data), - GFP_KERNEL); + interrupt_data = kzalloc(sizeof(*interrupt_data), GFP_KERNEL); if (!interrupt_data) return -ENOMEM; gasket_dev->interrupt_data = interrupt_data; @@ -336,17 +335,17 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev) interrupt_data->pack_width = driver_desc->interrupt_pack_width; interrupt_data->num_configured = 0; - interrupt_data->eventfd_ctxs = kcalloc(driver_desc->num_interrupts, - sizeof(struct eventfd_ctx *), - GFP_KERNEL); + interrupt_data->eventfd_ctxs = + kcalloc(driver_desc->num_interrupts, + sizeof(*interrupt_data->eventfd_ctxs), GFP_KERNEL); if (!interrupt_data->eventfd_ctxs) { kfree(interrupt_data); return -ENOMEM; } - interrupt_data->interrupt_counts = kcalloc(driver_desc->num_interrupts, - sizeof(ulong), - GFP_KERNEL); + interrupt_data->interrupt_counts = + kcalloc(driver_desc->num_interrupts, + sizeof(*interrupt_data->interrupt_counts), GFP_KERNEL); if (!interrupt_data->interrupt_counts) { kfree(interrupt_data->eventfd_ctxs); kfree(interrupt_data); diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index b7d460cf15fb..f5253ba9a430 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1278,7 +1278,8 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size, /* allocate the physical memory block */ gasket_dev->page_table[index]->coherent_pages = - kcalloc(num_pages, sizeof(struct gasket_coherent_page_entry), + kcalloc(num_pages, + sizeof(*gasket_dev->page_table[index]->coherent_pages), GFP_KERNEL); if (!gasket_dev->page_table[index]->coherent_pages) goto nomem;