[PATCH leds v3 5/9] leds: lm36274: use platform device as parent of LED

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

 



Instead of registering LED under the MFD device, this driver sets the
parent of the LED it is registering to the parent of the MFD device (the
I2C client device).

Because of this we cannot use devres for LED registration, since it can
result in use-after-free, see commit
a0972fff0947 ("leds: lm36274: fix use-after-free on unbind").

The only other in-tree driver that also registers under the MFD device
(drivers/regulator/lm363x-regulator.c) sets the parent to the MFD
device.

Set the parent of this LED to the MFD device, instead of the I2C client
device.

Signed-off-by: Marek Behún <marek.behun@xxxxxx>
Cc: Dan Murphy <dmurphy@xxxxxx>
---
 drivers/leds/leds-lm36274.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c
index 85a58a5cbdf9c..74c236d1a60c8 100644
--- a/drivers/leds/leds-lm36274.c
+++ b/drivers/leds/leds-lm36274.c
@@ -69,7 +69,7 @@ static int lm36274_init(struct lm36274 *chip)
 static int lm36274_parse_dt(struct lm36274 *chip,
 			    struct led_init_data *init_data)
 {
-	struct device *dev = &chip->pdev->dev;
+	struct device *dev = chip->dev;
 	struct fwnode_handle *child;
 	int ret;
 
@@ -118,7 +118,7 @@ static int lm36274_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	chip->pdev = pdev;
-	chip->dev = lmu->dev;
+	chip->dev = &pdev->dev;
 	chip->regmap = lmu->regmap;
 	platform_set_drvdata(pdev, chip);
 
-- 
2.26.2




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux