From: "Dr. David Alan Gilbert" <linux@treblig.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: rafael@kernel.org, dakr@kernel.org, johan@kernel.org,
driver-core@lists.linux.dev
Subject: Re: [PATCH] driver core: platform: Check for NULL name in platform_get_resource_byname
Date: Thu, 19 Nov 2026 13:37:51 +0000 [thread overview]
Message-ID: <av77r-cfY9p1KOAa@gallifrey> (raw)
In-Reply-To: <2026111930-swagger-emit-3a58@gregkh>
* Greg KH (gregkh@linuxfoundation.org) wrote:
> On Thu, Nov 19, 2026 at 12:18:20AM +0000, linux@treblig.org wrote:
> > From: "Dr. David Alan Gilbert" <linux@treblig.org>
> >
> > Drivers are calling platform_get_resource_byname() with a name string
> > derived from a DT. If that's a DT that's broken without the field
> > that should land in the name field, a NULL is passed and it OOPSs
> > in the strcmp. Check for a NULL name and return NULL; turning
> > a crash into one broken device.
>
> Nope, this is as-intended, fix the DT :)
This makes the difference between a machine
a) that panics and was leaving me at a black screen and
having to rely on pstore to figure out what happened (then
later once I knew the device I could then load the module later
after boot, but still then it made the module un-removable)
and
b) something where I get reasonable errors, I can unload
the module and reload it with function tracing on and figure
out which bit of the DT to fix easily.
which given that it's just the webcam is one hell of a difference.
If your worry is that it'll just leave people shipping even more broken
DTs then perhaps a WARN would help.
It would be good to have a kernel we can actually debug.
> Also:
>
> > @@ -464,6 +464,9 @@ struct resource *platform_get_resource_byname(struct platform_device *dev,
> > {
> > u32 i;
> >
> > + if (unlikely(!name))
> > + return NULL;
>
> Only ever use unlikely/likely if you can measure the difference with it
> not being there. For a call like this, you can't :)
OK, I was just being consistent with the check directly below it.
Dave
> thanks,
>
> greg k-h
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/
prev parent reply other threads:[~2026-11-19 13:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 0:18 [PATCH] driver core: platform: Check for NULL name in platform_get_resource_byname linux
2026-11-19 13:20 ` Greg KH
2026-11-19 13:37 ` Dr. David Alan Gilbert [this message]
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=av77r-cfY9p1KOAa@gallifrey \
--to=linux@treblig.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=rafael@kernel.org \
/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