From 63e3c092087bb1a8e0cf28a5358b025ecd18c5cd Mon Sep 17 00:00:00 2001 From: Arun-Prasad-V Date: Wed, 30 Oct 2024 20:14:48 +0530 Subject: [PATCH] d4xx: Locking on mux open and close --- kernel/realsense/d4xx.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/realsense/d4xx.c b/kernel/realsense/d4xx.c index 1d9efde..e8d09be 100644 --- a/kernel/realsense/d4xx.c +++ b/kernel/realsense/d4xx.c @@ -2827,9 +2827,16 @@ static int ds5_mux_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) struct ds5 *state = v4l2_get_subdevdata(sd); dev_dbg(sd->dev, "%s(): %s (%p)\n", __func__, sd->name, fh); + + mutex_lock(&state->lock); if (state->dfu_dev.dfu_state_flag) + { + mutex_unlock(&state->lock); return -EBUSY; + } + state->dfu_dev.device_open_count++; + mutex_unlock(&state->lock); return 0; }; @@ -2839,7 +2846,9 @@ static int ds5_mux_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) struct ds5 *state = v4l2_get_subdevdata(sd); dev_dbg(sd->dev, "%s(): %s (%p)\n", __func__, sd->name, fh); + mutex_lock(&state->lock); state->dfu_dev.device_open_count--; + mutex_unlock(&state->lock); return 0; };