[PATCH 01/10] media: microchip-isc: fix awb_mutex and lock lifecycle

From: Balakrishnan Sambath

Date: Tue Jun 16 2026 - 07:52:04 EST


isc_async_complete() initialised awb_mutex and isc->lock only after an
early error return, and the teardown was inconsistent:

- isc_async_unbind() destroyed awb_mutex before cancelling awb_work,
which takes it;
- a failed .complete() destroyed both locks, then the v4l2-async core
unbinds the subdev and isc_async_unbind() destroyed awb_mutex again;
- isc->lock was destroyed only on the .complete() error path, so the
normal unbind path leaked it.

Initialise both locks before the first error return, make unbind the
single teardown site (cancel the work, then destroy both locks) and
drop the destroys from the .complete() error path.

Fixes: 314c96e5203d ("media: atmel: atmel-isc-base: use mutex to lock awb workq from streaming")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@xxxxxxxxxxxxx>
---
drivers/media/platform/microchip/microchip-isc-base.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index a7cdc743fda7..45a7af779323 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1703,10 +1703,11 @@ static void isc_async_unbind(struct v4l2_async_notifier *notifier,
{
struct isc_device *isc = container_of(notifier->v4l2_dev,
struct isc_device, v4l2_dev);
- mutex_destroy(&isc->awb_mutex);
cancel_work_sync(&isc->awb_work);
+ mutex_destroy(&isc->awb_mutex);
video_unregister_device(&isc->video_dev);
v4l2_ctrl_handler_free(&isc->ctrls.handler);
+ mutex_destroy(&isc->lock);
}

struct isc_format *isc_find_format_by_code(struct isc_device *isc,
@@ -1758,6 +1759,8 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
int ret = 0;

INIT_WORK(&isc->awb_work, isc_awb_work);
+ mutex_init(&isc->lock);
+ mutex_init(&isc->awb_mutex);

ret = v4l2_device_register_subdev_nodes(&isc->v4l2_dev);
if (ret < 0) {
@@ -1767,8 +1770,6 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)

isc->current_subdev = container_of(notifier,
struct isc_subdev_entity, notifier);
- mutex_init(&isc->lock);
- mutex_init(&isc->awb_mutex);

init_completion(&isc->comp);

@@ -1841,8 +1842,6 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier)
video_unregister_device(vdev);

isc_async_complete_err:
- mutex_destroy(&isc->awb_mutex);
- mutex_destroy(&isc->lock);
return ret;
}


--
2.34.1