Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp991985ybt; Fri, 19 Jun 2020 20:51:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz58eIC2CpEIJh88catPSfpBM+iIs4f0mMoIBWr6bB0i1gQTTP39Q4G4zCTjWHjaAdtxxwE X-Received: by 2002:a05:6402:3078:: with SMTP id bs24mr6310183edb.284.1592625069453; Fri, 19 Jun 2020 20:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592625069; cv=none; d=google.com; s=arc-20160816; b=S80rHilcbk1RYX66dtEpJUevuehjjgbL/uVtcc68ok5sVRCOND3c7/V4mvCaqafbDK zM/TxsdbJ2rtqXqc/+SzrNNdxDQTUZ2PZQ+aHd55QV18oCU3KG7p26uQrVKywzOHsOJu Ulo+30XHNSKrDajSWnct+S9edRwYu+8s/5dMA2Ly05i7Xe4lH3B1/r8vSL06gnnXRCor H4yTm0JTZ5ArwlzOTEvjK1mGCU3jr81f3DJlx+100zYKUiyTdn3mzpHjnuRz+z1zgbHW E/CuSpDZUwAee4wLNA553gU6PZtH5GN1NdTYuTa2KV9hG/w43NWYqeB538LaIxv6wlSl Enkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zSd9F1qzlJygp8RJuxY1PuQgYnRqDLRDhC4KWQz5e7g=; b=pj0SRTvdX81YWq8Jwp6oOd1EwkKvxnnH9s3d6fPvzU2yW4O76UYYIuy1eHY9counES QvFLt8j6v5yTSGNbfwe5294FV9bbqcidMrB8VMr3xC4z6O765NInaNvdGXslUantJE2H y0qgAgmXsQr7JMikg8eVRP7kr8q4KTEw91oa3Ngf4ylwxye0VxuLxSkvlKR0kJ/zp54h GKtqmTpr0ucx2HJL/gLVdgOpjIlLPnsLGKo2sZb3RE/FbJxpKM/69RPrrhdrIhZildV6 N2F5pvdBuczoVfAiJEVF0RB8Bf8aJH1+S4h16Ker4QJVW/ydiUKhu516de1gvbPhqMja Ne8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hl3z1WCd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di10si4806229edb.84.2020.06.19.20.50.47; Fri, 19 Jun 2020 20:51:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hl3z1WCd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394478AbgFSQPv (ORCPT + 99 others); Fri, 19 Jun 2020 12:15:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:60196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391002AbgFSPD1 (ORCPT ); Fri, 19 Jun 2020 11:03:27 -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 85E4021841; Fri, 19 Jun 2020 15:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592579007; bh=UXODAnyXH2Tc+R2Su4d7FG46pp0SS5cd9xx6upBrECw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hl3z1WCdzEtyNxVWYYApOJ7ipS6W8bZwaJU302jzGyCxKKHzrYJkCnwOYRfrNIZjh uBQ9tSm1sc8HuAZt9r4/KF1orvRng6TfSsH7I923dchuCwIj9ZOscSCKieV8awAEEz Oc+QeD5zK3ysIgNfzeMBAQncprabguCL7aedeH80= 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 4.19 240/267] media: ov5640: fix use of destroyed mutex Date: Fri, 19 Jun 2020 16:33:45 +0200 Message-Id: <20200619141700.208218465@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -2829,8 +2829,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; } @@ -2840,9 +2840,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; }