Patch "regulator/core: regulator_register: set device->class earlier" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    regulator/core: regulator_register: set device->class earlier

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     regulator-core-regulator_register-set-device-class-e.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f5d426eddc1200d63ac70c42948c1bc1c971ee52
Author: Michał Mirosław <mirq-linux@xxxxxxxxxxxx>
Date:   Tue Sep 19 00:50:26 2023 +0200

    regulator/core: regulator_register: set device->class earlier
    
    [ Upstream commit 8adb4e647a83cb5928c05dae95b010224aea0705 ]
    
    When fixing a memory leak in commit d3c731564e09 ("regulator: plug
    of_node leak in regulator_register()'s error path") it moved the
    device_initialize() call earlier, but did not move the `dev->class`
    initialization.  The bug was spotted and fixed by reverting part of
    the commit (in commit 5f4b204b6b81 "regulator: core: fix kobject
    release warning and memory leak in regulator_register()") but
    introducing a different bug: now early error paths use `kfree(dev)`
    instead of `put_device()` for an already initialized `struct device`.
    
    Move the missing assignments to just after `device_initialize()`.
    
    Fixes: d3c731564e09 ("regulator: plug of_node leak in regulator_register()'s error path")
    Signed-off-by: Michał Mirosław <mirq-linux@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/b5b19cb458c40c9d02f3d5a7bd1ba7d97ba17279.1695077303.git.mirq-linux@xxxxxxxxxxxx
    Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 351f0fd225b14..f6a95f72af18d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5543,6 +5543,8 @@ regulator_register(struct device *dev,
 		goto rinse;
 	}
 	device_initialize(&rdev->dev);
+	dev_set_drvdata(&rdev->dev, rdev);
+	rdev->dev.class = &regulator_class;
 	spin_lock_init(&rdev->err_lock);
 
 	/*
@@ -5604,11 +5606,9 @@ regulator_register(struct device *dev,
 		rdev->supply_name = regulator_desc->supply_name;
 
 	/* register with sysfs */
-	rdev->dev.class = &regulator_class;
 	rdev->dev.parent = config->dev;
 	dev_set_name(&rdev->dev, "regulator.%lu",
 		    (unsigned long) atomic_inc_return(&regulator_no));
-	dev_set_drvdata(&rdev->dev, rdev);
 
 	/* set regulator constraints */
 	if (init_data)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux