Skip to content

Commit e7ce902

Browse files
claudiubezneagregkh
authored andcommitted
iio: adc: rzg2l_adc: Set driver data before enabling runtime PM
commit c69e139 upstream. When stress-testing the system by repeatedly unbinding and binding the ADC device in a loop, and the ADC is a supplier for another device (e.g., a thermal hardware block that reads temperature through the ADC), it may happen that the ADC device is runtime-resumed immediately after runtime PM is enabled, triggered by its consumer. At this point, since drvdata is not yet set and the driver's runtime PM callbacks rely on it, a crash can occur. To avoid this, set drvdata just after it was allocated. Fixes: 89ee817 ("iio: adc: rzg2l_adc: Simplify the runtime PM code") Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Link: https://patch.msgid.link/20250810123328.800104-3-claudiu.beznea.uj@bp.renesas.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f93f84b commit e7ce902

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/iio/adc/rzg2l_adc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
428428
if (!indio_dev)
429429
return -ENOMEM;
430430

431+
platform_set_drvdata(pdev, indio_dev);
432+
431433
adc = iio_priv(indio_dev);
432434

433435
adc->hw_params = device_get_match_data(dev);
@@ -460,8 +462,6 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
460462
if (ret)
461463
return ret;
462464

463-
platform_set_drvdata(pdev, indio_dev);
464-
465465
ret = rzg2l_adc_hw_init(dev, adc);
466466
if (ret)
467467
return dev_err_probe(&pdev->dev, ret,

0 commit comments

Comments
 (0)