From 3fe797a12bfa9a49aa998ee722e5f25c957b9b15 Mon Sep 17 00:00:00 2001 From: Jurison Murati Date: Wed, 10 Jun 2026 12:22:36 +0200 Subject: [PATCH] media: i2c: ov8865: Drop the runtime PM usage count on stream failure ov8865_s_stream() takes a runtime PM reference when enabling the stream, but returns without releasing it if ov8865_sw_standby() fails, leaving the reference unbalanced and the sensor powered indefinitely. The same applies to a failure while disabling the stream, in which case the reference acquired at stream start is never dropped. Drop the reference in a single place, both when disabling the stream and on failure, and only update the streaming state on success. Signed-off-by: Jurison Murati Reviewed-by: Daniel Scally Signed-off-by: Sakari Ailus --- drivers/media/i2c/ov8865.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c index a8586df14f77..5b909a856128 100644 --- a/drivers/media/i2c/ov8865.c +++ b/drivers/media/i2c/ov8865.c @@ -2621,15 +2621,13 @@ static int ov8865_s_stream(struct v4l2_subdev *subdev, int enable) ret = ov8865_sw_standby(sensor, !enable); mutex_unlock(&sensor->mutex); - if (ret) - return ret; - - state->streaming = !!enable; - - if (!enable) + if (ret || !enable) pm_runtime_put(sensor->dev); - return 0; + if (!ret) + state->streaming = enable; + + return ret; } static const struct v4l2_subdev_video_ops ov8865_subdev_video_ops = {