public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Sudeep Holla <sudeep.holla@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Subject: Re: [bug report] firmware: arm_ffa: Add schedule receiver callback mechanism
Date: Tue, 31 Oct 2023 07:15:45 +0300	[thread overview]
Message-ID: <5ff13821-5b37-4dca-90ee-7fa54f7adffa@kadam.mountain> (raw)
In-Reply-To: <ZT_TQ7bdCG6CjYqW@bogus>

On Mon, Oct 30, 2023 at 04:01:07PM +0000, Sudeep Holla wrote:
> On Mon, Oct 30, 2023 at 05:31:04PM +0300, Dan Carpenter wrote:
> > Hello Sudeep Holla,
> > 
> > The patch 0184450b8b1e: "firmware: arm_ffa: Add schedule receiver
> > callback mechanism" from Oct 5, 2023 (linux-next), leads to the
> > following Smatch static checker warning:
> > 
> > 	drivers/firmware/arm_ffa/driver.c:1251 ffa_partitions_cleanup()
> > 	warn: double check that we're allocating correct size: 8 vs 88
> > 
> > drivers/firmware/arm_ffa/driver.c
> >     1243 static void ffa_partitions_cleanup(void)
> >     1244 {
> >     1245         struct ffa_dev_part_info **info;
> >     1246         int idx, count = drv_info->partition_count;
> >     1247 
> >     1248         if (!count)
> >     1249                 return;
> >     1250 
> > --> 1251         info = kcalloc(count, sizeof(**info), GFP_KERNEL);
> > 
> > I *think* this should be sizeof(*info).  It ends up being a smaller
> > allocation (8 bytes instead of 88).
> 
> Not sure if I am following this warning properly. I am bit confused whether
> it suggest 8 is correct or 88 is correct. Anyways, the expectation is to
> just allocate 8 bytes for a pointer. We just fetch a list of stored pointer
> in XArray and free them.
> 
> One possible way to avoid any confusion is to use sizeof(struct ffa_dev_part_info *)
> or even sizeof(void *).

The static checker is saying that 8 is correct but we are allocating 88
bytes.  There is an extra * in the sizeof().

I don't necessarily like to make buffers smaller in case I have
misunderstood the code, but it seems like we should do that here.

regards,
dan carpenter


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-10-31  4:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-30 14:31 [bug report] firmware: arm_ffa: Add schedule receiver callback mechanism Dan Carpenter
2023-10-30 16:01 ` Sudeep Holla
2023-10-31  4:15   ` Dan Carpenter [this message]
2023-10-31  9:50     ` Sudeep Holla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5ff13821-5b37-4dca-90ee-7fa54f7adffa@kadam.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox