lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANiDSCvbZ+kUCCYV0OKEBXha5Mfpk4-vkhSWcnvjzh89LfLufQ@mail.gmail.com>
Date: Wed, 3 Dec 2025 14:17:45 +0100
From: Ricardo Ribalda <ribalda@...omium.org>
To: Laurent Pinchart <laurent.pinchart@...asonboard.com>
Cc: Keke Li <keke.li@...ogic.com>, Jacopo Mondi <jacopo.mondi@...asonboard.com>, 
	Daniel Scally <dan.scally@...asonboard.com>, Hans Verkuil <hverkuil+cisco@...nel.org>, 
	Vikash Garodia <vikash.garodia@....qualcomm.com>, 
	Dikshita Agarwal <dikshita.agarwal@....qualcomm.com>, Abhinav Kumar <abhinav.kumar@...ux.dev>, 
	"Bryan O'Donoghue" <bod@...nel.org>, Mauro Carvalho Chehab <mchehab@...nel.org>, 
	Sakari Ailus <sakari.ailus@...ux.intel.com>, linux-media@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH 2/3] media: iris: Document difference in size during allocation

Hi Laurent



On Wed, 3 Dec 2025 at 10:17, Laurent Pinchart
<laurent.pinchart@...asonboard.com> wrote:
>
> On Wed, Dec 03, 2025 at 08:55:35AM +0000, Ricardo Ribalda wrote:
> > As we get ready for kzalloc checking for invalid sizes, let's add
> > documentation for the cases where the size is different but valid.
> >
> > This patch fixes this cocci warning:
> > ./platform/qcom/iris/iris_hfi_gen2_command.c:1215:9-25: WARNING: casting value returned by memory allocation function to (struct iris_inst *) is useless.
> >
> > Signed-off-by: Ricardo Ribalda <ribalda@...omium.org>
> > ---
> >  drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> > index f9129553209922fda548ca320494ae6ae797854c..ab91afd0597045bd876d0411b08b5a3421b12c70 100644
> > --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> > +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c
> > @@ -1212,5 +1212,13 @@ void iris_hfi_gen2_command_ops_init(struct iris_core *core)
> >
> >  struct iris_inst *iris_hfi_gen2_get_instance(void)
> >  {
> > -     return (struct iris_inst *)kzalloc(sizeof(struct iris_inst_hfi_gen2), GFP_KERNEL);
> > +     struct iris_inst_hfi_gen2 *out;
> > +
> > +     /*
> > +      * The allocation is intentionally larger. The first member of
> > +      * struct iris_hfi_gen2 is struct iris_inst.
> > +      */
> > +     out = kzalloc(sizeof(*out), GFP_KERNEL);
> > +
> > +     return (struct iris_inst *)out;
>
>         return &out->inst;
>
> would be more readable. You can then drop the comment.

It looks better, and it is more robust. Thanks

I prefer to leave a small comment though:

+       struct iris_inst_hfi_gen2 *out;
+
+       /* The allocation is intentionally larger than struct iris_inst. */
+       out = kzalloc(sizeof(*out), GFP_KERNEL);
+
+       return &out->inst;


Regards

>
> >  }
> >
>
> --
> Regards,
>
> Laurent Pinchart



-- 
Ricardo Ribalda

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ