Skip to content

Commit 298d147

Browse files
Mathis Foersthverkuil
authored andcommitted
media: mt9m114: Fix deadlock in get_frame_interval/set_frame_interval
Getting / Setting the frame interval using the V4L2 subdev pad ops get_frame_interval/set_frame_interval causes a deadlock, as the subdev state is locked in the [1] but also in the driver itself. In [2] it's described that the caller is responsible to acquire and release the lock in this case. Therefore, acquiring the lock in the driver is wrong. Remove the lock acquisitions/releases from mt9m114_ifp_get_frame_interval() and mt9m114_ifp_set_frame_interval(). [1] drivers/media/v4l2-core/v4l2-subdev.c - line 1129 [2] Documentation/driver-api/media/v4l2-subdev.rst Fixes: 24d756e ("media: i2c: Add driver for onsemi MT9M114 camera sensor") Cc: stable@vger.kernel.org Signed-off-by: Mathis Foerst <mathis.foerst@mt.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
1 parent 3aa7c3d commit 298d147

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

drivers/media/i2c/mt9m114.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,13 +1619,9 @@ static int mt9m114_ifp_get_frame_interval(struct v4l2_subdev *sd,
16191619
if (interval->which != V4L2_SUBDEV_FORMAT_ACTIVE)
16201620
return -EINVAL;
16211621

1622-
mutex_lock(sensor->ifp.hdl.lock);
1623-
16241622
ival->numerator = 1;
16251623
ival->denominator = sensor->ifp.frame_rate;
16261624

1627-
mutex_unlock(sensor->ifp.hdl.lock);
1628-
16291625
return 0;
16301626
}
16311627

@@ -1644,8 +1640,6 @@ static int mt9m114_ifp_set_frame_interval(struct v4l2_subdev *sd,
16441640
if (interval->which != V4L2_SUBDEV_FORMAT_ACTIVE)
16451641
return -EINVAL;
16461642

1647-
mutex_lock(sensor->ifp.hdl.lock);
1648-
16491643
if (ival->numerator != 0 && ival->denominator != 0)
16501644
sensor->ifp.frame_rate = min_t(unsigned int,
16511645
ival->denominator / ival->numerator,
@@ -1659,8 +1653,6 @@ static int mt9m114_ifp_set_frame_interval(struct v4l2_subdev *sd,
16591653
if (sensor->streaming)
16601654
ret = mt9m114_set_frame_rate(sensor);
16611655

1662-
mutex_unlock(sensor->ifp.hdl.lock);
1663-
16641656
return ret;
16651657
}
16661658

0 commit comments

Comments
 (0)