[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D7PH9S5RQ3L8.2ZAE5MLH5PN5Y@gmail.com>
Date: Tue, 11 Feb 2025 03:36:23 -0500
From: "Kurt Borja" <kuurtb@...il.com>
To: "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>
Cc: <linux-kernel@...r.kernel.org>, "Lyude Paul" <lyude@...hat.com>, "Rafael
J. Wysocki" <rafael@...nel.org>, "Danilo Krummrich" <dakr@...nel.org>,
"Alexander Lobakin" <aleksander.lobakin@...el.com>, "Andy Shevchenko"
<andriy.shevchenko@...ux.intel.com>, "Bjorn Helgaas" <bhelgaas@...gle.com>,
"Jonathan Cameron" <Jonathan.Cameron@...wei.com>, "Liam Girdwood"
<lgirdwood@...il.com>, "Lukas Wunner" <lukas@...ner.de>, "Mark Brown"
<broonie@...nel.org>, Maíra Canal <mairacanal@...eup.net>,
"Robin Murphy" <robin.murphy@....com>, "Simona Vetter"
<simona.vetter@...ll.ch>, "Zijun Hu" <quic_zijuhu@...cinc.com>,
<linux-usb@...r.kernel.org>, <rust-for-linux@...r.kernel.org>,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Subject: Re: [PATCH v4 1/9] driver core: add a faux bus for use when a
simple device/bus is needed
On Tue Feb 11, 2025 at 3:17 AM -05, Greg Kroah-Hartman wrote:
> On Tue, Feb 11, 2025 at 02:43:20AM -0500, Kurt Borja wrote:
>> On Tue Feb 11, 2025 at 2:33 AM -05, Greg Kroah-Hartman wrote:
>> > On Tue, Feb 11, 2025 at 08:27:26AM +0100, Greg Kroah-Hartman wrote:
>> >> On Mon, Feb 10, 2025 at 12:56:46PM -0500, Kurt Borja wrote:
>> >> I'll work on adding "if probe failed, don't let the device be created"
>> >> logic as it's a simple change, BUT it is a functionally different change
>> >> from what the current api that this code is replacing is doing (i.e. the
>> >> current platform device creation code does this today and no one has
>> >> ever hit this in their use of it in the past few decades.)
>> >
>> > How about something as simple as this change, does that provide what you
>> > are thinking about here? Only compile tested, not runtime tested at
>> > all:
>>
>> Yes, LGTM. However dev->driver is set to NULL if the probe fails so
>> wouldn't
>>
>> if (!dev->driver)
>>
>> do the job?
>
> True, that would work, and be much simpler, I'll go add that AND
> actually test it :)
Nice :)
>
>> I understand your point about groups. This of course solves it, although
>> isn't there a small windows between device_add() and device_destroy() in
>> the failed probe path, in which a show/store/visibility method could
>> dereference a NULL drvdata?
>
> Ok, I looked it up and it turns out that the groups wouldn't have even
> been created if probe() failed (see the call to call_driver_probe() in
> really_probe() in drivers/base/dd.c) So all should be good here.
Are you refering to this line [1]? Because those are the driver's
dev_groups.
dev->groups are added by device_add_attrs() in device_add(). Here is the
line [2]. This happens *way* before the device is added to the bus.
Also I tested with a sample faux device (faux faux device :)) and the
groups do get added, even if the probe fails.
[1] https://elixir.bootlin.com/linux/v6.14-rc1/source/drivers/base/core.c#L2887
[2] https://elixir.bootlin.com/linux/v6.14-rc1/source/drivers/base/core.c#L2887
--
~ Kurt
>
> thanks,
>
> greg k-h
Powered by blists - more mailing lists