[PATCH 2/3] sgi-xpc: Improve a size determination in two functions

From: SF Markus Elfring
Date: Wed Jan 10 2018 - 09:05:41 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Jan 2018 14:18:12 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
drivers/misc/sgi-xp/xpc_uv.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/sgi-xp/xpc_uv.c b/drivers/misc/sgi-xp/xpc_uv.c
index 0c95f9994649..8a8dfcbbe729 100644
--- a/drivers/misc/sgi-xp/xpc_uv.c
+++ b/drivers/misc/sgi-xp/xpc_uv.c
@@ -212,10 +212,9 @@ xpc_create_gru_mq_uv(unsigned int mq_size, int cpu, char *irq_name,
int nasid;
int pg_order;
struct page *page;
- struct xpc_gru_mq_uv *mq;
struct uv_IO_APIC_route_entry *mmr_value;
+ struct xpc_gru_mq_uv *mq = kmalloc(sizeof(*mq), GFP_KERNEL);

- mq = kmalloc(sizeof(struct xpc_gru_mq_uv), GFP_KERNEL);
if (mq == NULL) {
ret = -ENOMEM;
goto out_0;
@@ -686,9 +685,7 @@ xpc_send_activate_IRQ_uv(struct xpc_partition *part, void *msg, size_t msg_size,
if (!(part_uv->flags & XPC_P_CACHED_ACTIVATE_GRU_MQ_DESC_UV)) {
gru_mq_desc = part_uv->cached_activate_gru_mq_desc;
if (gru_mq_desc == NULL) {
- gru_mq_desc = kmalloc(sizeof(struct
- gru_message_queue_desc),
- GFP_KERNEL);
+ gru_mq_desc = kmalloc(sizeof(*gru_mq_desc), GFP_KERNEL);
if (gru_mq_desc == NULL) {
ret = xpNoMemory;
goto done;
--
2.15.1