linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: ov5640: fix use of destroyed mutex
@ 2020-03-13  8:22 Tomi Valkeinen
  2020-03-13 11:45 ` Laurent Pinchart
  2020-03-13 13:19 ` [PATCH v2] " Tomi Valkeinen
  0 siblings, 2 replies; 5+ messages in thread
From: Tomi Valkeinen @ 2020-03-13  8:22 UTC (permalink / raw)
  To: Steve Longerbeam, Mauro Carvalho Chehab, linux-media, Benoit Parrot
  Cc: Laurent Pinchart, Tomi Valkeinen, stable

v4l2_ctrl_handler_free() uses hdl->lock, which in ov5640 driver is set
to sensor's own sensor->lock. In ov5640_remove(), the driver destroys the
sensor->lock first, and then calls v4l2_ctrl_handler_free(), resulting
in the use of the destroyed mutex.

Fix this by calling v4l2_ctrl_handler_free() before mutex_destroy().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: stable@vger.kernel.org
---
 drivers/media/i2c/ov5640.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 854031f0b64a..64511de4eea8 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -3104,9 +3104,9 @@ static int ov5640_remove(struct i2c_client *client)
 	struct ov5640_dev *sensor = to_ov5640_dev(sd);
 
 	v4l2_async_unregister_subdev(&sensor->sd);
+	v4l2_ctrl_handler_free(&sensor->ctrls.handler);
 	mutex_destroy(&sensor->lock);
 	media_entity_cleanup(&sensor->sd.entity);
-	v4l2_ctrl_handler_free(&sensor->ctrls.handler);
 
 	return 0;
 }
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-25 12:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13  8:22 [PATCH] media: ov5640: fix use of destroyed mutex Tomi Valkeinen
2020-03-13 11:45 ` Laurent Pinchart
2020-03-13 13:19 ` [PATCH v2] " Tomi Valkeinen
2020-03-19 21:59   ` Benoit Parrot
2020-03-25 12:20   ` [PATCH v3] " Tomi Valkeinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).