From patchwork Tue Apr 14 10:18:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 227960 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E55CC2BB86 for ; Tue, 14 Apr 2020 10:33:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 238C620644 for ; Tue, 14 Apr 2020 10:33:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586860408; bh=LqOUXqd4GXjAoW32FvVfqDBM1hjFWtccXxcOJo+mfag=; h=From:Date:Subject:To:Cc:Reply-to:List-ID:From; b=2sVBT0c9ZBH0NT2JibUconQKrLH0VMjrWnksVI3HeA1ncVEG9mBegMVySjhQQzyvJ OG4WmMYdNeHitrR/ewdOyaRqVImEeOGltjfOHnphzJT6rQkqqtv0S0+aqJGkgSHCmo TMBASv+LqQWbHccMHH5zhsi2X+tyCUvEtrFEop24= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438383AbgDNKdK (ORCPT ); Tue, 14 Apr 2020 06:33:10 -0400 Received: from www.linuxtv.org ([130.149.80.248]:39870 "EHLO www.linuxtv.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438363AbgDNKc7 (ORCPT ); Tue, 14 Apr 2020 06:32:59 -0400 Received: from mchehab by www.linuxtv.org with local (Exim 4.92) (envelope-from ) id 1jOIpK-001Ok4-DG; Tue, 14 Apr 2020 10:29:58 +0000 From: Mauro Carvalho Chehab Date: Tue, 14 Apr 2020 10:18:37 +0000 Subject: [git:media_tree/master] media: ov5640: fix use of destroyed mutex To: linuxtv-commits@linuxtv.org Cc: stable@vger.kernel.org, Sakari Ailus , Tomi Valkeinen , Benoit Parrot , Laurent Pinchart Mail-followup-to: linux-media@vger.kernel.org Forward-to: linux-media@vger.kernel.org Reply-to: linux-media@vger.kernel.org Message-Id: Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is an automatic generated email to let you know that the following patch were queued: Subject: media: ov5640: fix use of destroyed mutex Author: Tomi Valkeinen Date: Wed Mar 25 13:20:00 2020 +0100 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 moving the mutex_destroy() to the end of the cleanup sequence, as there's no need to destroy the mutex as early as possible. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart Cc: stable@vger.kernel.org # v4.14+ Reviewed-by: Benoit Parrot Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab drivers/media/i2c/ov5640.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 854031f0b64a..2fe4a7ac0592 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -3093,8 +3093,8 @@ static int ov5640_probe(struct i2c_client *client) free_ctrls: v4l2_ctrl_handler_free(&sensor->ctrls.handler); entity_cleanup: - mutex_destroy(&sensor->lock); media_entity_cleanup(&sensor->sd.entity); + mutex_destroy(&sensor->lock); return ret; } @@ -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); - mutex_destroy(&sensor->lock); media_entity_cleanup(&sensor->sd.entity); v4l2_ctrl_handler_free(&sensor->ctrls.handler); + mutex_destroy(&sensor->lock); return 0; }