* [PATCH] media: atomisp: add missing mutex in atomisp_vidioc_default()
@ 2026-02-05 4:37 Ziyi Guo
2026-02-05 6:26 ` Andy Shevchenko
2026-03-10 8:50 ` Sakari Ailus
0 siblings, 2 replies; 3+ messages in thread
From: Ziyi Guo @ 2026-02-05 4:37 UTC (permalink / raw)
To: Hans de Goede, Mauro Carvalho Chehab, Andy Shevchenko
Cc: Sakari Ailus, Greg Kroah-Hartman, linux-media, linux-staging,
linux-kernel, Ziyi Guo
atomisp_vidioc_default() calls atomisp_exp_id_unlock(),
atomisp_exp_id_capture(), and atomisp_inject_a_fake_event() without
holding isp->mutex. However, all three functions have
lockdep_assert_held(&isp->mutex) indicating callers must hold this lock.
Other ioctl handlers in the same driver (e.g., atomisp_start_streaming)
properly acquire the mutex before operating on ISP state.
Add mutex_lock()/mutex_unlock() around these three ioctl cases to fix the
missing lock protection.
Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
---
drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
index bb8b2f2213b0..ab13630c8149 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
@@ -1521,10 +1521,14 @@ static long atomisp_vidioc_default(struct file *file, void *fh,
break;
case ATOMISP_IOC_EXP_ID_UNLOCK:
+ mutex_lock(&asd->isp->mutex);
err = atomisp_exp_id_unlock(asd, arg);
+ mutex_unlock(&asd->isp->mutex);
break;
case ATOMISP_IOC_EXP_ID_CAPTURE:
+ mutex_lock(&asd->isp->mutex);
err = atomisp_exp_id_capture(asd, arg);
+ mutex_unlock(&asd->isp->mutex);
break;
case ATOMISP_IOC_S_ENABLE_DZ_CAPT_PIPE:
err = atomisp_enable_dz_capt_pipe(asd, arg);
@@ -1537,7 +1541,9 @@ static long atomisp_vidioc_default(struct file *file, void *fh,
err = atomisp_formats(asd, 1, arg);
break;
case ATOMISP_IOC_INJECT_A_FAKE_EVENT:
+ mutex_lock(&asd->isp->mutex);
err = atomisp_inject_a_fake_event(asd, arg);
+ mutex_unlock(&asd->isp->mutex);
break;
case ATOMISP_IOC_S_ARRAY_RESOLUTION:
err = atomisp_set_array_res(asd, arg);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] media: atomisp: add missing mutex in atomisp_vidioc_default()
2026-02-05 4:37 [PATCH] media: atomisp: add missing mutex in atomisp_vidioc_default() Ziyi Guo
@ 2026-02-05 6:26 ` Andy Shevchenko
2026-03-10 8:50 ` Sakari Ailus
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-02-05 6:26 UTC (permalink / raw)
To: Ziyi Guo
Cc: Hans de Goede, Mauro Carvalho Chehab, Andy Shevchenko,
Sakari Ailus, Greg Kroah-Hartman, linux-media, linux-staging,
linux-kernel
On Thu, Feb 5, 2026 at 6:37 AM Ziyi Guo <n7l8m4@u.northwestern.edu> wrote:
>
> atomisp_vidioc_default() calls atomisp_exp_id_unlock(),
> atomisp_exp_id_capture(), and atomisp_inject_a_fake_event() without
> holding isp->mutex. However, all three functions have
> lockdep_assert_held(&isp->mutex) indicating callers must hold this lock.
Did you get a splat on real HW?
> Other ioctl handlers in the same driver (e.g., atomisp_start_streaming)
> properly acquire the mutex before operating on ISP state.
>
> Add mutex_lock()/mutex_unlock() around these three ioctl cases to fix the
> missing lock protection.
How did you find the issue?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: atomisp: add missing mutex in atomisp_vidioc_default()
2026-02-05 4:37 [PATCH] media: atomisp: add missing mutex in atomisp_vidioc_default() Ziyi Guo
2026-02-05 6:26 ` Andy Shevchenko
@ 2026-03-10 8:50 ` Sakari Ailus
1 sibling, 0 replies; 3+ messages in thread
From: Sakari Ailus @ 2026-03-10 8:50 UTC (permalink / raw)
To: Ziyi Guo
Cc: Hans de Goede, Mauro Carvalho Chehab, Andy Shevchenko,
Greg Kroah-Hartman, linux-media, linux-staging, linux-kernel
Hi Ziyi,
On Thu, Feb 05, 2026 at 04:37:30AM +0000, Ziyi Guo wrote:
> atomisp_vidioc_default() calls atomisp_exp_id_unlock(),
> atomisp_exp_id_capture(), and atomisp_inject_a_fake_event() without
> holding isp->mutex. However, all three functions have
> lockdep_assert_held(&isp->mutex) indicating callers must hold this lock.
>
> Other ioctl handlers in the same driver (e.g., atomisp_start_streaming)
> properly acquire the mutex before operating on ISP state.
>
> Add mutex_lock()/mutex_unlock() around these three ioctl cases to fix the
> missing lock protection.
>
> Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
We're disabling these for now so the locking question is no longer
relevant.
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-10 8:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-05 4:37 [PATCH] media: atomisp: add missing mutex in atomisp_vidioc_default() Ziyi Guo
2026-02-05 6:26 ` Andy Shevchenko
2026-03-10 8:50 ` Sakari Ailus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox