Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2489663pxj; Mon, 10 May 2021 04:20:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn5VFEIKm1FbbQeUYzctJekc3wBPbDu1py64MnlcMS5FqOij3YJHDpS5wr8ozFonfG756h X-Received: by 2002:aa7:c9cf:: with SMTP id i15mr29015356edt.4.1620645655245; Mon, 10 May 2021 04:20:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645655; cv=none; d=google.com; s=arc-20160816; b=IDiqmVxexAtcTtpPVmyIb7PBen92xISzjgyzCpTWr368LC9GEM4PecwypzuBP5LLVw BqvFjrDsnPQYnyvcWtB1laTkPuppOkNmMat9ISl2LcYgUpWODdIETylz4ZoxM86DOr97 is/vaykdrO/Bpxekvnd1OBl5oaC4TCWbhwtYt0xg74u0CPdNXW5WdnBttTR7Iln6EBeJ SAzAr9+/EUKCI5z3eDLJvD3NxqO2d8I1irBc+307UTDbFEgRkjZ9qfLIQaQfJQLJ1Sep FYbmSEM2pBIA4PWyrLL6jatOCm9Dk4LDeh5btFxiOu8ffA5l4MO6DuWWq6C3evcA/mvB 7BIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GI6qVZfJX+R2jb6S8i6/KvvGy1dHaPJ2QRg/nYQajxM=; b=jgWmY/q/igk8YMSntouolQX0dej7zSkq2SVTDlmfnnFbOUYyJlJESyp6wp8E5HmymV qXrAShec/ZztgvoY38R4pXXevhf2u1uPbAjbb/KCFJVjT+GQ3Qcfrx1DFrti26+2OcUl ys3hmCSPL3oOPyGqUHOckj8o7vJxj6VeCRB8DlUbWyThNAWm3oVB0FrdvLM/AqYN1EZz EuUMCE/sWQih4WE2EW7QJGcMhu1U2QLrVjf4rMGMTQXwO5i90vbyLIudqlDbIlLHVDUk iBv7bPWINvAwZ/DGHD4ZYPSfFxrcKj6tX7d77ZgkMqne3747avkOpL63Q/TdMKNzeT7D zyQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Hryk/7bq"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si12552199edr.586.2021.05.10.04.20.31; Mon, 10 May 2021 04:20:55 -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=@linuxfoundation.org header.s=korg header.b="Hryk/7bq"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236817AbhEJLKb (ORCPT + 99 others); Mon, 10 May 2021 07:10:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:59374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232951AbhEJKtR (ORCPT ); Mon, 10 May 2021 06:49:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 85268619C4; Mon, 10 May 2021 10:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643094; bh=j5njG6kfjfeKS8Pe74lDvSoVoXEqAO/FDdLBo589vLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hryk/7bqDAqz7a2F4P9IyUxmhMNdLiIEt4iyLrscpuECWSFL1WF7pkKWMKeyJc9xd Bp+8fyy1r1QU13cOZdlXC0adjmgThdD+W0B/EV5C0jXJnZT6Tw4U4zdkxTBrjyhvea ESen6qdwep58uETN00kuyzjXA4K4rsnsexJ2bVkc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yang Yingliang , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 176/299] media: tc358743: fix possible use-after-free in tc358743_remove() Date: Mon, 10 May 2021 12:19:33 +0200 Message-Id: <20210510102010.770371950@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit 6107a4fdf8554a7aa9488bdc835bb010062fa8a9 ] This driver's remove path calls cancel_delayed_work(). However, that function does not wait until the work function finishes. This means that the callback function may still be running after the driver's remove function has finished, which would result in a use-after-free. Fix by calling cancel_delayed_work_sync(), which ensures that the work is properly cancelled, no longer running, and unable to re-schedule itself. Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/tc358743.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c index 831b5b54fd78..1b309bb743c7 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c @@ -2193,7 +2193,7 @@ static int tc358743_remove(struct i2c_client *client) del_timer_sync(&state->timer); flush_work(&state->work_i2c_poll); } - cancel_delayed_work(&state->delayed_work_enable_hotplug); + cancel_delayed_work_sync(&state->delayed_work_enable_hotplug); cec_unregister_adapter(state->cec_adap); v4l2_async_unregister_subdev(sd); v4l2_device_unregister_subdev(sd); -- 2.30.2