[2/2] Revert "regulator: core: fix kobject release warning and memory leak in regulator_register()"

Message ID d7361cf5c6bfc78f519149554eadad1d5ef5e76f.1694985959.git.mirq-linux@rere.qmqm.pl
State New
Headers
Series regulator/core: A quick fix for struct device handling |

Commit Message

Michał Mirosław Sept. 17, 2023, 9:35 p.m. UTC
  This reverts commit 5f4b204b6b8153923d5be8002c5f7082985d153f.

Since rdev->dev now has a release() callback, the proper way of freeing
the initialized device can be restored.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/regulator/core.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
  

Comments

Mark Brown Sept. 18, 2023, 12:05 p.m. UTC | #1
On Sun, Sep 17, 2023 at 11:35:14PM +0200, Michał Mirosław wrote:
> This reverts commit 5f4b204b6b8153923d5be8002c5f7082985d153f.
> 
> Since rdev->dev now has a release() callback, the proper way of freeing
> the initialized device can be restored.

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.

Please include human readable descriptions of things like commits and
issues being discussed in e-mail in your mails, this makes them much
easier for humans to read especially when they have no internet access.
I do frequently catch up on my mail on flights or while otherwise
travelling so this is even more pressing for me than just being about
making things a bit easier to read.
  

Patch

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 2f6ee5527cb0..0994caa5ad5c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5724,15 +5724,11 @@  regulator_register(struct device *dev,
 	mutex_lock(&regulator_list_mutex);
 	regulator_ena_gpio_free(rdev);
 	mutex_unlock(&regulator_list_mutex);
-	put_device(&rdev->dev);
-	rdev = NULL;
 clean:
 	if (dangling_of_gpiod)
 		gpiod_put(config->ena_gpiod);
-	if (rdev && rdev->dev.of_node)
-		of_node_put(rdev->dev.of_node);
-	kfree(rdev);
 	kfree(config);
+	put_device(&rdev->dev);
 rinse:
 	if (dangling_cfg_gpiod)
 		gpiod_put(cfg->ena_gpiod);