Skip to content

Commit

Permalink
leds: lm36274: use platform device as parent of LED
Browse files Browse the repository at this point in the history
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
a0972ff ("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 <[email protected]>
Tested-by: Dan Murphy <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
  • Loading branch information
elkablo authored and pavelmachek committed Sep 26, 2020
1 parent 4844567 commit 5c0d20a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/leds/leds-lm36274.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 5c0d20a

Please sign in to comment.