Skip to contentSkip to conversation

firmware: microchip: Fix over-requested allocation size

PATCH In review Dawei Li 2 participants 2 messages Mar 4, 2024

Subsystems (2)
lore
Share & tools
lore

Dawei Li

author
#0 lore raw

PATCH v2 1/1 firmware: microchip: Fix over-requested allocation size

cocci warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/firmware/microchip/mpfs-auto-update.c:387:72-78:

ERROR: application of sizeof to pointer drivers/firmware/microchip/mpfs-auto-update.c:170:72-78:
ERROR: application of sizeof to pointer

response_msg is a pointer to u32, so the size of element it points to is supposed to be a multiple of sizeof(u32), rather than sizeof(u32 *).

---

V1 -> V2:
sizeof(u32)->sizeof(*response_msg)

V1:
https://lore.kernel.org/lkml/[email protected]/

 drivers/firmware/microchip/mpfs-auto-update.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/firmware/microchip/mpfs-auto-update.c +2 -1
index 682e417be5a3..fbeeaee4ac85 100644
@@ -384,7 +384,8 @@ static int mpfs_auto_update_available(struct mpfs_auto_update_priv *priv)
 	u32 *response_msg;
 	int ret;
 
-	response_msg = devm_kzalloc(priv->dev, AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof(response_msg),
+	response_msg = devm_kzalloc(priv->dev,
+				    AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof(*response_msg),
 				    GFP_KERNEL);
 	if (!response_msg)
 		return -ENOMEM;
Signature · 1 line
2.27.0
#1 lore raw
Quoted 9 lines · Dawei Li

cocci warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/firmware/microchip/mpfs-auto-update.c:387:72-78:

ERROR: application of sizeof to pointer drivers/firmware/microchip/mpfs-auto-update.c:170:72-78:
ERROR: application of sizeof to pointer

response_msg is a pointer to u32, so the size of element it points to is supposed to be a multiple of sizeof(u32), rather than sizeof(u32 *).

Quoted 7 lines

---

V1 -> V2:
sizeof(u32)->sizeof(*response_msg)

Thanks for the quick respin. I'll send this as 6.9 material cos of the proximity to the merge window and the fact that we just over-allocate here. Thanks!

I added a Fixes: tag when I applied this, you should add those in the future. I should've mentioned this earlier but forgot.

Thanks,
Conor.

https://git.kernel.org/conor/c/af1e0a7d39f98c0dea1b186a76fcee7da6a5f7bc