From: Jean-Philippe Brucker <jpb@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: Ryan Roberts <ryan.roberts@arm.com>, dri-devel@lists.freedesktop.org
Subject: Re: [RFC PATCH v1 3/8] misc/arm-cla: Probe firmware-described devices
Date: Wed, 30 Sep 2026 12:53:05 +0100 [thread overview]
Message-ID: <20260930115305.GC480985@myrica> (raw)
In-Reply-To: <20260717105709.172911F000E9@smtp.kernel.org>
On Fri, Jul 17, 2026 at 10:57:08AM +0000, sashiko-bot@kernel.org wrote:
> > diff --git a/drivers/misc/arm-cla/cla-topology.c b/drivers/misc/arm-cla/cla-topology.c
> > --- /dev/null
> > +++ b/drivers/misc/arm-cla/cla-topology.c
>
> [ ... ]
>
> > +struct cla_domain *cla_dev_domain_get(struct cla_dev *dev)
> > +{
> > + int ret;
> > + unsigned int domain_id;
> > + struct cla_domain *domain;
> > +
> > + /* Domain ID is provided by firmware */
> > + ret = of_property_read_u32(dev->dev->of_node, "domain", &domain_id);
> > + if (WARN_ON(ret))
> > + return ERR_PTR(-EINVAL);
> > +
> > + domain = xa_load(&cla_domains, domain_id);
> > + if (domain) {
> > + domain->nr_devs++;
> > + domain->devs = krealloc_array(domain->devs, domain->nr_devs,
> > + sizeof(*domain->devs), GFP_KERNEL);
>
> [Severity: High]
> Does this code leak the original domain->devs array if krealloc_array() fails
> and returns NULL?
Yes, needs fix
> Also, since domain->nr_devs was unconditionally incremented,
> will a subsequent call to cla_domains_finalise() dereference the NULL
> pointer at domain->devs[j]?
No subsequent call
>
> > + if (!domain->devs)
> > + return ERR_PTR(-ENOMEM);
> > + domain->devs[domain->nr_devs - 1] = dev;
> > + return domain;
> > + }
> > +
> > + domain = cla_domain_alloc(dev, domain_id);
> > + if (IS_ERR(domain))
> > + return domain;
> > +
> > + cla_nr_domains = max(domain_id + 1, cla_nr_domains);
>
> [Severity: Medium]
> Can this calculation overflow to 0 if firmware provides a domain_id of
> UINT_MAX? If it overflows, will cla_domains_finalise() skip its loop and
> leave the device uninitialized in the lookup tables?
FW does not provide UINT_MAX as domain ID
next prev parent reply other threads:[~2026-09-30 11:52 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 10:47 [RFC PATCH v1 0/8] Arm Core Local Accelerator Driver Ryan Roberts
2026-07-17 10:47 ` [RFC PATCH v1 1/8] misc/arm-cla: Add driver skeleton and documentation Ryan Roberts
2026-07-17 10:56 ` sashiko-bot
2026-09-30 11:51 ` Jean-Philippe Brucker
2026-07-17 13:49 ` Arnd Bergmann
2026-07-17 15:44 ` Ryan Roberts
2026-07-17 16:10 ` Arnd Bergmann
2026-07-20 9:54 ` Ryan Roberts
2026-07-17 10:47 ` [RFC PATCH v1 2/8] misc/arm-cla: Add launch operation helpers Ryan Roberts
2026-07-17 11:01 ` sashiko-bot
2026-09-30 11:52 ` Jean-Philippe Brucker
2026-07-17 12:16 ` Arnd Bergmann
2026-08-04 11:03 ` Jean-Philippe Brucker
2026-07-17 10:47 ` [RFC PATCH v1 3/8] misc/arm-cla: Probe firmware-described devices Ryan Roberts
2026-07-17 10:57 ` sashiko-bot
2026-09-30 11:53 ` Jean-Philippe Brucker [this message]
2026-07-17 12:25 ` Arnd Bergmann
2026-07-17 12:36 ` Ryan Roberts
2026-07-17 10:47 ` [RFC PATCH v1 4/8] misc/arm-cla: Initialize devices on CPU bringup Ryan Roberts
2026-07-17 10:58 ` sashiko-bot
2026-09-30 11:54 ` Jean-Philippe Brucker
2026-07-17 10:47 ` [RFC PATCH v1 5/8] misc/arm-cla: Accelerator context save and restore Ryan Roberts
2026-07-17 10:58 ` sashiko-bot
2026-09-30 11:55 ` Jean-Philippe Brucker
2026-07-17 10:47 ` [RFC PATCH v1 6/8] misc/arm-cla: Set up memory translation context Ryan Roberts
2026-07-17 11:02 ` sashiko-bot
2026-09-30 11:56 ` Jean-Philippe Brucker
2026-07-17 10:47 ` [RFC PATCH v1 7/8] misc/arm-cla: Manage domain contexts Ryan Roberts
2026-07-17 11:01 ` sashiko-bot
2026-09-30 11:57 ` Jean-Philippe Brucker
2026-07-17 10:47 ` [RFC PATCH v1 8/8] misc/arm-cla: Add userspace interface Ryan Roberts
2026-07-17 11:10 ` sashiko-bot
2026-09-30 11:58 ` Jean-Philippe Brucker
2026-07-17 12:54 ` Arnd Bergmann
2026-07-17 14:35 ` Ryan Roberts
2026-07-17 15:31 ` Arnd Bergmann
2026-07-17 16:21 ` Ryan Roberts
2026-07-17 20:11 ` Arnd Bergmann
2026-08-19 16:08 ` Ryan Roberts
2026-07-17 11:33 ` [RFC PATCH v1 0/8] Arm Core Local Accelerator Driver Will Deacon
2026-07-17 12:09 ` Marc Zyngier
2026-07-17 12:33 ` Ryan Roberts
2026-07-19 7:47 ` Marc Zyngier
2026-07-17 12:30 ` Ryan Roberts
2026-07-17 13:32 ` Jason Gunthorpe
2026-07-17 13:42 ` Ryan Roberts
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=20260930115305.GC480985@myrica \
--to=jpb@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ryan.roberts@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.