Skip to content

Commit fe6402e

Browse files
jhovoldgregkh
authored andcommitted
leds: 88pm860x: fix use-after-free on unbind
commit eca21c2 upstream. Several MFD child drivers register their class devices directly under the parent device. This means you cannot blindly do devres conversions so that deregistration ends up being tied to the parent device, something which leads to use-after-free on driver unbind when the class device is released while still being registered. Fixes: 375446d ("leds: 88pm860x: Use devm_led_classdev_register") Cc: stable <[email protected]> # 4.6 Cc: Amitoj Kaur Chawla <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Signed-off-by: Pavel Machek <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3564cdd commit fe6402e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/leds/leds-88pm860x.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,33 @@ static int pm860x_led_probe(struct platform_device *pdev)
203203
data->cdev.brightness_set_blocking = pm860x_led_set;
204204
mutex_init(&data->lock);
205205

206-
ret = devm_led_classdev_register(chip->dev, &data->cdev);
206+
ret = led_classdev_register(chip->dev, &data->cdev);
207207
if (ret < 0) {
208208
dev_err(&pdev->dev, "Failed to register LED: %d\n", ret);
209209
return ret;
210210
}
211211
pm860x_led_set(&data->cdev, 0);
212+
213+
platform_set_drvdata(pdev, data);
214+
212215
return 0;
213216
}
214217

218+
static int pm860x_led_remove(struct platform_device *pdev)
219+
{
220+
struct pm860x_led *data = platform_get_drvdata(pdev);
221+
222+
led_classdev_unregister(&data->cdev);
223+
224+
return 0;
225+
}
215226

216227
static struct platform_driver pm860x_led_driver = {
217228
.driver = {
218229
.name = "88pm860x-led",
219230
},
220231
.probe = pm860x_led_probe,
232+
.remove = pm860x_led_remove,
221233
};
222234

223235
module_platform_driver(pm860x_led_driver);

0 commit comments

Comments
 (0)