Skip to content

Commit 31f453e

Browse files
linuswjic23
authored andcommitted
iio: pressure: bmp280: fix runtime suspend/resume crash
In commit 3d83811 ("iio: pressure: bmp280: add power management") For some reason the code in the runtime suspend/resume hooks got wrong (I suspect in the ambition to cut down boilerplate) and it seems it was tested without CONFIG_PM and crashes like so for me: Unable to handle kernel NULL pointer dereference at virtual address 0000000c pgd = c0204000 [0000000c] *pgd=00000000 Internal error: Oops: 5 [tobetter#1] PREEMPT SMP ARM Modules linked in: CPU: 1 PID: 89 Comm: kworker/1:2 Not tainted 4.7.0-03348-g90dc3680458a-dirty torvalds#99 Hardware name: Generic DT based system Workqueue: pm pm_runtime_work task: df3c6300 ti: dec8a000 task.ti: dec8a000 PC is at regulator_disable+0x0/0x6c LR is at bmp280_runtime_suspend+0x3c/0xa4 Dereferencing the BMP280 state container properly fixes the problem, sorry for screwing up. Fixes: 3d83811 ("iio: pressure: bmp280: add power management") Signed-off-by: Linus Walleij <[email protected]> Tested-by: Jarkko Nikula <[email protected]> Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 193e2d4 commit 31f453e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/iio/pressure/bmp280-core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove);
10791079
#ifdef CONFIG_PM
10801080
static int bmp280_runtime_suspend(struct device *dev)
10811081
{
1082-
struct bmp280_data *data = dev_get_drvdata(dev);
1082+
struct iio_dev *indio_dev = dev_get_drvdata(dev);
1083+
struct bmp280_data *data = iio_priv(indio_dev);
10831084
int ret;
10841085

10851086
ret = regulator_disable(data->vdda);
@@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev)
10901091

10911092
static int bmp280_runtime_resume(struct device *dev)
10921093
{
1093-
struct bmp280_data *data = dev_get_drvdata(dev);
1094+
struct iio_dev *indio_dev = dev_get_drvdata(dev);
1095+
struct bmp280_data *data = iio_priv(indio_dev);
10941096
int ret;
10951097

10961098
ret = regulator_enable(data->vddd);

0 commit comments

Comments
 (0)