firmware: microchip: Fix over-requested allocation size
Subsystems (2)
PATCH 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 *).
--- drivers/firmware/microchip/mpfs-auto-update.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/microchip/mpfs-auto-update.c +1 -1
@@ -384,7 +384,7 @@ 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 (u32),GFP_KERNEL );if (!response_msg)return -ENOMEM ;
Signature · 1 line
2.27.0
Conor Dooley
maintainerHey,
Quoted 21 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_msgis a pointer to u32, so the size of element it points to is supposed to be a multiple of sizeof(u32), rather thansizeof(u32 *).Reported-by kernel test robot <[email protected]>Signed-off-by Dawei Li <[email protected]>--- drivers/firmware/microchip/mpfs-auto-update.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/firmware/microchip/mpfs-auto-update.c +0
-0
drivers/firmware/microchip/mpfs-auto-update.c static int mpfs_auto_update_available(struct mpfs_auto_update_priv *priv) · line 387
Quoted 5 lines
drivers/firmware/microchip/mpfs-auto-update.c +1
-1@@ -384,7 +384,7 @@ 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(u32),
Why not use sizeof(*response_msg)?
Cheers,
Conor.
Quoted 6 lines
drivers/firmware/microchip/mpfs-auto-update.c +0
-0GFP_KERNEL);if (!response_msg)return -ENOMEM ;Signature · 1 line
2.27.0
Hi Conor,
Thanks for the quick review.
Quoted 27 lines · Conor Dooley
Hey,
Quoted 24 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_msgis a pointer to u32, so the size of element it points to is supposed to be a multiple of sizeof(u32), rather thansizeof(u32 *).Reported-by kernel test robot <[email protected]>Signed-off-by Dawei Li <[email protected]>--- drivers/firmware/microchip/mpfs-auto-update.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/firmware/microchip/mpfs-auto-update.c +0
-0@@ -384,7 +384,7 @@ static int mpfs_auto_update_available(struct mpfs_auto_update_priv *priv)u32 *response_msg;int ret;
Quoted 4 lines
drivers/firmware/microchip/mpfs-auto-update.c static int mpfs_auto_update_available(struct mpfs_auto_update_priv *priv) · line 387
Quoted 2 lines
drivers/firmware/microchip/mpfs-auto-update.c +1
-1- 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(u32),Why not use
sizeof(*response_msg)?
Because checkpatch complains about 100-character violation and I don't want to wrap lines :)
I will respin V2 as you suggested.
Thanks,
Dawei
Quoted 10 lines
Cheers,
Conor.Quoted 6 lines
drivers/firmware/microchip/mpfs-auto-update.c +0
-0GFP_KERNEL);if (!response_msg)return -ENOMEM ;Signature · 1 line
2.27.0