driver core: auxiliary bus: fix OF node leak
Subsystems (2)
Johan Hovold
maintainerPATCH 1/1 driver core: auxiliary bus: fix OF node leak
Make sure to drop the OF node reference taken when creating an auxiliary device using auxiliary_device_create() when the device is later released.
--- drivers/base/auxiliary.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/base/auxiliary.c +2 -0
@@ -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 ; }
Signature · 1 line
2.49.0
Leon Romanovsky
reviewerQuoted 3 lines · 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.
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
Quoted 31 lines
Fixes eaa0d30216c1 ("driver core: auxiliary bus: add device creation helpers")Cc Jerome Brunet <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- drivers/base/auxiliary.c | 2 ++ 1 file changed, 2 insertions(+)drivers/base/auxiliary.c +2
-0@@ -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 ; }Signature · 1 line
2.49.0
Johan Hovold
maintainerQuoted 8 lines · Leon Romanovsky
Quoted 3 lines · 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.I'm probably missing something, but random grep for the
device_set_of_node_from_dev()callers shows that none of them are calling toof_node_put()explicitly.
Yeah, the platform bus code takes care of dropping the reference for platform devices.
Johan
Jerome Brunet
Reviewed-byQuoted 6 lines · Johan Hovold
Quoted 5 lines · Leon Romanovsky
Quoted 3 lines · 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.
Quoted 6 lines
Quoted 3 lines
I'm probably missing something, but random grep for the
device_set_of_node_from_dev()callers shows that none of them are calling toof_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
Quoted 2 lines
Johan
Signature · 1 line
Jerome
Quoted 7 lines · 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 <[email protected]>Signed-off-by Johan Hovold <[email protected]>