Skip to contentSkip to conversation

iio: pressure: bmp280: Fix incorrect pointer access in PM callbacks

PATCH In review Jarkko Nikula 3 participants 4 messages Aug 12, 2016 – Aug 15, 2016 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: pressure: bmp280: Fix incorrect pointer access in PM callbacks

BMP280 runtime PM callbacks are incorrectly casting dev_get_drvdata() to struct bmp280_data * while bmp280_common_probe() sets driver data to struct iio_dev *. Fix this and get the struct bmp280_data * from private data of struct iio_dev.

Fixes 3d838118c6aa ("iio: pressure: bmp280: add power management")

---
For v4.8-rc.

---
 drivers/iio/pressure/bmp280-core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iio/pressure/bmp280-core.c +4 -2
index 6943688e66df..724fefd4af00 100644
@@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove);
 #ifdef CONFIG_PM
 static int bmp280_runtime_suspend(struct device *dev)
 {
-	struct bmp280_data *data = dev_get_drvdata(dev);
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
 
 	ret = regulator_disable(data->vdda);
@@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev)
 
 static int bmp280_runtime_resume(struct device *dev)
 {
-	struct bmp280_data *data = dev_get_drvdata(dev);
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
 
 	ret = regulator_enable(data->vddd);
Signature · 1 line
2.8.1
#1 lore raw
Quoted 9 lines · Jarkko Nikula

BMP280 runtime PM callbacks are incorrectly casting dev_get_drvdata() to struct bmp280_data * while bmp280_common_probe() sets driver data to struct iio_dev *. Fix this and get the struct bmp280_data * from private data of struct iio_dev.

Fixes 3d838118c6aa ("iio: pressure: bmp280: add power management")

---
For v4.8-rc.

Sent a fix for this already two weeks ago:
http://marc.info/?l=linux-iio&m=146965159217655&w=2

Just waiting for it to be picked up and merged.

Yours,
Linus Walleij

author Tested-by
#2 lore raw
Quoted 13 lines · Linus Walleij
Quoted 9 lines · Jarkko Nikula

BMP280 runtime PM callbacks are incorrectly casting dev_get_drvdata() to struct bmp280_data * while bmp280_common_probe() sets driver data to struct iio_dev *. Fix this and get the struct bmp280_data * from private data of struct iio_dev.

Fixes 3d838118c6aa ("iio: pressure: bmp280: add power management")

---
For v4.8-rc.

Quoted 5 lines

Sent a fix for this already two weeks ago:
http://marc.info/?l=linux-iio&m=146965159217655&w=2

Just waiting for it to be picked up and merged.

Ok, please feel free to add my tested by to your patch then

maintainer
#3 lore raw
Quoted 14 lines · Jarkko Nikula
Quoted 13 lines · Linus Walleij
Quoted 9 lines · Jarkko Nikula

BMP280 runtime PM callbacks are incorrectly casting dev_get_drvdata() to struct bmp280_data * while bmp280_common_probe() sets driver data to struct iio_dev *. Fix this and get the struct bmp280_data * from private data of struct iio_dev.

Fixes 3d838118c6aa ("iio: pressure: bmp280: add power management")

---
For v4.8-rc.

Quoted 8 lines
Quoted 5 lines

Sent a fix for this already two weeks ago:
http://marc.info/?l=linux-iio&m=146965159217655&w=2

Just waiting for it to be picked up and merged.

Ok, please feel free to add my tested by to your patch then

Added.