* [PATCH] firmware: microchip: Fix over-requested allocation size
@ 2024-03-04 9:25 Dawei Li
2024-03-04 9:52 ` Conor Dooley
0 siblings, 1 reply; 3+ messages in thread
From: Dawei Li @ 2024-03-04 9:25 UTC (permalink / raw)
To: conor.dooley, daire.mcnamara, linux-riscv, linux-kernel
Cc: Dawei Li, kernel test robot
cocci warnings: (new ones prefixed by >>)
>> 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 *).
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202403040516.CYxoWTXw-lkp@intel.com/
Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
---
drivers/firmware/microchip/mpfs-auto-update.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/microchip/mpfs-auto-update.c b/drivers/firmware/microchip/mpfs-auto-update.c
index 682e417be5a3..7ea3cdb917bc 100644
--- a/drivers/firmware/microchip/mpfs-auto-update.c
+++ b/drivers/firmware/microchip/mpfs-auto-update.c
@@ -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;
--
2.27.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] firmware: microchip: Fix over-requested allocation size
2024-03-04 9:25 [PATCH] firmware: microchip: Fix over-requested allocation size Dawei Li
@ 2024-03-04 9:52 ` Conor Dooley
2024-03-04 10:01 ` Dawei Li
0 siblings, 1 reply; 3+ messages in thread
From: Conor Dooley @ 2024-03-04 9:52 UTC (permalink / raw)
To: Dawei Li; +Cc: daire.mcnamara, linux-riscv, linux-kernel, kernel test robot
[-- Attachment #1: Type: text/plain, Size: 1534 bytes --]
Hey,
On Mon, Mar 04, 2024 at 05:25:32PM +0800, Dawei Li wrote:
> cocci warnings: (new ones prefixed by >>)
> >> 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 *).
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202403040516.CYxoWTXw-lkp@intel.com/
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> ---
> drivers/firmware/microchip/mpfs-auto-update.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/microchip/mpfs-auto-update.c b/drivers/firmware/microchip/mpfs-auto-update.c
> index 682e417be5a3..7ea3cdb917bc 100644
> --- a/drivers/firmware/microchip/mpfs-auto-update.c
> +++ b/drivers/firmware/microchip/mpfs-auto-update.c
> @@ -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.
> GFP_KERNEL);
> if (!response_msg)
> return -ENOMEM;
> --
> 2.27.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] firmware: microchip: Fix over-requested allocation size
2024-03-04 9:52 ` Conor Dooley
@ 2024-03-04 10:01 ` Dawei Li
0 siblings, 0 replies; 3+ messages in thread
From: Dawei Li @ 2024-03-04 10:01 UTC (permalink / raw)
To: Conor Dooley; +Cc: daire.mcnamara, linux-riscv, linux-kernel, kernel test robot
Hi Conor,
Thanks for the quick review.
On Mon, Mar 04, 2024 at 09:52:52AM +0000, Conor Dooley wrote:
> Hey,
>
> On Mon, Mar 04, 2024 at 05:25:32PM +0800, Dawei Li wrote:
> > cocci warnings: (new ones prefixed by >>)
> > >> 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 *).
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202403040516.CYxoWTXw-lkp@intel.com/
> > Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> > ---
> > drivers/firmware/microchip/mpfs-auto-update.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/microchip/mpfs-auto-update.c b/drivers/firmware/microchip/mpfs-auto-update.c
> > index 682e417be5a3..7ea3cdb917bc 100644
> > --- a/drivers/firmware/microchip/mpfs-auto-update.c
> > +++ b/drivers/firmware/microchip/mpfs-auto-update.c
> > @@ -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)`?
Because checkpatch complains about 100-character violation and I don't
want to wrap lines :)
I will respin V2 as you suggested.
Thanks,
Dawei
>
> Cheers,
> Conor.
>
> > GFP_KERNEL);
> > if (!response_msg)
> > return -ENOMEM;
> > --
> > 2.27.0
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-04 10:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 9:25 [PATCH] firmware: microchip: Fix over-requested allocation size Dawei Li
2024-03-04 9:52 ` Conor Dooley
2024-03-04 10:01 ` Dawei Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®