mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
iio: light: apds9306: fix PM reference leak in apds9306_read_data()
apds9306_read_data() calls pm_runtime_resume_and_get() but several
error paths return directly without calling pm_runtime_put_autosuspend(),
leaking the runtime PM reference and preventing the device from
autosuspending.
Use PM_RUNTIME_ACQUIRE_AUTOSUSPEND() and PM_RUNTIME_ACQUIRE_ERR() to
automatically handle runtime PM reference release on all return paths.
Fixes: 620d1e6c7a ("iio: light: Add support for APDS9306 Light Sensor")
Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
This commit is contained in:
parent
06fab97602
commit
d378fceaaf
|
|
@ -469,9 +469,9 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg)
|
|||
int status = 0;
|
||||
u8 buff[3];
|
||||
|
||||
ret = pm_runtime_resume_and_get(data->dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
PM_RUNTIME_ACQUIRE_AUTOSUSPEND(data->dev, pm);
|
||||
if (PM_RUNTIME_ACQUIRE_ERR(&pm))
|
||||
return PM_RUNTIME_ACQUIRE_ERR(&pm);
|
||||
|
||||
ret = regmap_field_read(rf->intg_time, &intg_time_idx);
|
||||
if (ret)
|
||||
|
|
@ -535,8 +535,6 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg)
|
|||
|
||||
*val = get_unaligned_le24(&buff);
|
||||
|
||||
pm_runtime_put_autosuspend(data->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user