[PATCH] iio: adc: viperboard: Call platform_set_drvdata before devm_iio_device_register

From: Johannes Thumshirn
Date: Sat Feb 01 2014 - 09:40:17 EST


Call platform_set_drvdata before devm_iio_device_register to avoid possible
race condition when accessing driver data.

Signed-off-by: Johannes Thumshirn <morbidrsa@xxxxxxxxx>
---
drivers/iio/adc/viperboard_adc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c
index d0add8f..7d9bd05 100644
--- a/drivers/iio/adc/viperboard_adc.c
+++ b/drivers/iio/adc/viperboard_adc.c
@@ -133,14 +133,14 @@ static int vprbrd_adc_probe(struct platform_device *pdev)
indio_dev->channels = vprbrd_adc_iio_channels;
indio_dev->num_channels = ARRAY_SIZE(vprbrd_adc_iio_channels);

+ platform_set_drvdata(pdev, indio_dev);
+
ret = devm_iio_device_register(&pdev->dev, indio_dev);
if (ret) {
dev_err(&pdev->dev, "could not register iio (adc)");
return ret;
}

- platform_set_drvdata(pdev, indio_dev);
-
return 0;
}

--
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/