From patchwork Fri Jun 19 14:33:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 224014 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 7025FC433DF for ; Fri, 19 Jun 2020 15:37:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C14A20786 for ; Fri, 19 Jun 2020 15:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592581076; bh=Bu+NPimlJpWa6hgqy91S1oh2Af6/PWbtnMCu6p7EQos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QvpzBcpeZ3E1pESqHhapYdxqUW9kvc1YdpqrwgRnpDPTsdgGdLiI8wuUZ760Ew5In 48ecr4VjcYrAOv9TGYDLzGevj+M6UEdwJjtbMecUdObaGc0OCVLDcmP2G7ogpSzbbx pKpdYduFedDN7NhbclofTvHE5iXugXdziTN/zU74= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405138AbgFSPhp (ORCPT ); Fri, 19 Jun 2020 11:37:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:33532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404686AbgFSP3y (ORCPT ); Fri, 19 Jun 2020 11:29:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E05020734; Fri, 19 Jun 2020 15:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580592; bh=Bu+NPimlJpWa6hgqy91S1oh2Af6/PWbtnMCu6p7EQos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vor9HJnpg+Z7kFuQ3MAIYFfPdbCbH65qU58zV/FuVYgKAKKkc+sl4fhqn4xeJZ8eW 7CMwFkthHAwNHf/nS0EsiXJIvRapJK7cw82nbE6fewW0ulqstSrsGGlZSsr0hr+E/6 fyi819Vz3HYY4WH/s2YYNg6wPKRJt37+5NnaVkec= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomi Valkeinen , Laurent Pinchart , Benoit Parrot , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH 5.7 307/376] media: ov5640: fix use of destroyed mutex Date: Fri, 19 Jun 2020 16:33:45 +0200 Message-Id: <20200619141724.868498090@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tomi Valkeinen commit bfcba38d95a0aed146a958a84a2177af1459eddc upstream. 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 Signed-off-by: Greg Kroah-Hartman --- drivers/media/i2c/ov5640.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -3093,8 +3093,8 @@ static int ov5640_probe(struct i2c_clien 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_clie 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; }