linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] driver core: auxiliary bus: fix OF node leak
@ 2025-07-08  8:46 Johan Hovold
  2025-07-08  9:59 ` Leon Romanovsky
  2025-07-08 14:39 ` Danilo Krummrich
  0 siblings, 2 replies; 5+ messages in thread
From: Johan Hovold @ 2025-07-08  8:46 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dave Ertman, Ira Weiny, Leon Romanovsky, Rafael J. Wysocki,
	Danilo Krummrich, Jerome Brunet, linux-kernel, Johan Hovold

Make sure to drop the OF node reference taken when creating an auxiliary
device using auxiliary_device_create() when the device is later
released.

Fixes: eaa0d30216c1 ("driver core: auxiliary bus: add device creation helpers")
Cc: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/base/auxiliary.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
index dba7c8e13a53..6bdefebf3609 100644
--- a/drivers/base/auxiliary.c
+++ b/drivers/base/auxiliary.c
@@ -399,6 +399,7 @@ static void auxiliary_device_release(struct device *dev)
 {
 	struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
 
+	of_node_put(dev->of_node);
 	kfree(auxdev);
 }
 
@@ -435,6 +436,7 @@ struct auxiliary_device *auxiliary_device_create(struct device *dev,
 
 	ret = auxiliary_device_init(auxdev);
 	if (ret) {
+		of_node_put(auxdev->dev.of_node);
 		kfree(auxdev);
 		return NULL;
 	}
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] driver core: auxiliary bus: fix OF node leak
  2025-07-08  8:46 [PATCH] driver core: auxiliary bus: fix OF node leak Johan Hovold
@ 2025-07-08  9:59 ` Leon Romanovsky
  2025-07-08 10:04   ` Johan Hovold
  2025-07-08 14:39 ` Danilo Krummrich
  1 sibling, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2025-07-08  9:59 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
	Danilo Krummrich, Jerome Brunet, linux-kernel

On Tue, Jul 08, 2025 at 10:46:54AM +0200, Johan Hovold wrote:
> Make sure to drop the OF node reference taken when creating an auxiliary
> device using auxiliary_device_create() when the device is later
> released.

I'm probably missing something, but random grep for the
device_set_of_node_from_dev() callers shows that none of them are
calling to of_node_put() explicitly.

Thanks

> 
> Fixes: eaa0d30216c1 ("driver core: auxiliary bus: add device creation helpers")
> Cc: Jerome Brunet <jbrunet@baylibre.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/base/auxiliary.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c
> index dba7c8e13a53..6bdefebf3609 100644
> --- a/drivers/base/auxiliary.c
> +++ b/drivers/base/auxiliary.c
> @@ -399,6 +399,7 @@ static void auxiliary_device_release(struct device *dev)
>  {
>  	struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
>  
> +	of_node_put(dev->of_node);
>  	kfree(auxdev);
>  }
>  
> @@ -435,6 +436,7 @@ struct auxiliary_device *auxiliary_device_create(struct device *dev,
>  
>  	ret = auxiliary_device_init(auxdev);
>  	if (ret) {
> +		of_node_put(auxdev->dev.of_node);
>  		kfree(auxdev);
>  		return NULL;
>  	}
> -- 
> 2.49.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] driver core: auxiliary bus: fix OF node leak
  2025-07-08  9:59 ` Leon Romanovsky
@ 2025-07-08 10:04   ` Johan Hovold
  2025-07-08 14:38     ` Jerome Brunet
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hovold @ 2025-07-08 10:04 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Rafael J. Wysocki,
	Danilo Krummrich, Jerome Brunet, linux-kernel

On Tue, Jul 08, 2025 at 12:59:08PM +0300, Leon Romanovsky wrote:
> On Tue, Jul 08, 2025 at 10:46:54AM +0200, Johan Hovold wrote:
> > Make sure to drop the OF node reference taken when creating an auxiliary
> > device using auxiliary_device_create() when the device is later
> > released.
> 
> I'm probably missing something, but random grep for the
> device_set_of_node_from_dev() callers shows that none of them are
> calling to of_node_put() explicitly.

Yeah, the platform bus code takes care of dropping the reference for
platform devices.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] driver core: auxiliary bus: fix OF node leak
  2025-07-08 10:04   ` Johan Hovold
@ 2025-07-08 14:38     ` Jerome Brunet
  0 siblings, 0 replies; 5+ messages in thread
From: Jerome Brunet @ 2025-07-08 14:38 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Leon Romanovsky, Greg Kroah-Hartman, Dave Ertman, Ira Weiny,
	Rafael J. Wysocki, Danilo Krummrich, linux-kernel

On Tue 08 Jul 2025 at 12:04, Johan Hovold <johan@kernel.org> wrote:

> On Tue, Jul 08, 2025 at 12:59:08PM +0300, Leon Romanovsky wrote:
>> On Tue, Jul 08, 2025 at 10:46:54AM +0200, Johan Hovold wrote:
>> > Make sure to drop the OF node reference taken when creating an auxiliary
>> > device using auxiliary_device_create() when the device is later
>> > released.
>> 
>> I'm probably missing something, but random grep for the
>> device_set_of_node_from_dev() callers shows that none of them are
>> calling to of_node_put() explicitly.
>
> Yeah, the platform bus code takes care of dropping the reference for
> platform devices.

There is an of_node_get() that needs balancing indeed, Thanks

Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>

>
> Johan

-- 
Jerome

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] driver core: auxiliary bus: fix OF node leak
  2025-07-08  8:46 [PATCH] driver core: auxiliary bus: fix OF node leak Johan Hovold
  2025-07-08  9:59 ` Leon Romanovsky
@ 2025-07-08 14:39 ` Danilo Krummrich
  1 sibling, 0 replies; 5+ messages in thread
From: Danilo Krummrich @ 2025-07-08 14:39 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Dave Ertman, Ira Weiny, Leon Romanovsky,
	Rafael J. Wysocki, Jerome Brunet, linux-kernel

On 7/8/25 10:46 AM, Johan Hovold wrote:
> Make sure to drop the OF node reference taken when creating an auxiliary
> device using auxiliary_device_create() when the device is later
> released.
> 
> Fixes: eaa0d30216c1 ("driver core: auxiliary bus: add device creation helpers")
> Cc: Jerome Brunet <jbrunet@baylibre.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Danilo Krummrich <dakr@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-08 14:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08  8:46 [PATCH] driver core: auxiliary bus: fix OF node leak Johan Hovold
2025-07-08  9:59 ` Leon Romanovsky
2025-07-08 10:04   ` Johan Hovold
2025-07-08 14:38     ` Jerome Brunet
2025-07-08 14:39 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).