From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Steve Longerbeam <slongerbeam@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-media@vger.kernel.org, Benoit Parrot <bparrot@ti.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] media: ov5640: fix use of destroyed mutex
Date: Fri, 13 Mar 2020 13:45:40 +0200 [thread overview]
Message-ID: <20200313114540.GA4751@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20200313082258.6930-1-tomi.valkeinen@ti.com>
Hi Tomi,
Thank you for the patch.
On Fri, Mar 13, 2020 at 10:22:58AM +0200, Tomi Valkeinen wrote:
> 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);
While at it, could you move the mutex after media_entity_cleanup() too,
to avoid future problems in case it gets used through that path ?
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> return 0;
> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2020-03-13 11:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 8:22 [PATCH] media: ov5640: fix use of destroyed mutex Tomi Valkeinen
2020-03-13 11:45 ` Laurent Pinchart [this message]
2020-03-13 13:19 ` [PATCH v2] " Tomi Valkeinen
2020-03-17 22:30 ` Sasha Levin
2020-03-19 21:59 ` Benoit Parrot
2020-03-25 12:20 ` [PATCH v3] " Tomi Valkeinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200313114540.GA4751@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=bparrot@ti.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=slongerbeam@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tomi.valkeinen@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).