Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp303266pxj; Thu, 20 May 2021 09:40:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMUlaMPsn4TZBjry41RmyyQJupDktyWf1NvDADOGnMgJpavhY7wS6L7XEVxx83+T4dDgRE X-Received: by 2002:a05:6402:5211:: with SMTP id s17mr6085387edd.352.1621528817241; Thu, 20 May 2021 09:40:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621528817; cv=none; d=google.com; s=arc-20160816; b=0mxdIMGHvKYTHGaLqBdq7z/FosVBMFer2FDp2+V/7FG0SP+76SZb8aFRC4VejC75P0 8ew8CFUNHBEkNcGeocal+/2/O7E3mFNbOgEDKmaKjqmNPoHVQmOBSxlpXBRT2Zck9VUe QezjyDD0MchKaEFLQNwAH+EvH+sJWZeSlEE7RU6p5aikuYeDtRU9veJ8HonhEUr0UOn6 km5+VHYre8RegJr5VY2IDHzhIjR/5HCvS4/90JMAripcWzFycskfW2IJTWoIEcvpU5kx 4IlQO+q+Z4ZqZwpok5ImYdjXm70xq0oqwlOPlRKOwrgTEHCDU03VdX6Ktgu+SSc2LJyd 2a+g== 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=p+JoA+OOYB7V8SHfRM5PcBqpriWKzyf4iu+GViJCtDE=; b=el/FEdCJxaZ6ZQUMLZ68Zrwp19fhByIrVEE45lM5rmx2HRQGWynGGa0ZVbWWKKlt97 FaeWerOr2W4s9za97LxIw09M+13BnJT8osEgop1a8uAfMMEIXa50eDKYCLdXadfyzRwd 8hSEeOkrABD4sHw3vqHS2nTpxqNGUAUgqgpfEEXnUl1eo+O2avEwzi5mhMhQFn3YBPkp O/aj22jZWpA75LQvDP82RsoQEXPYbWSBw3b819nkYkOofuYvT5cfEp6Yi6+/xb5P4kJ/ eFSrLmXq7Ruq1XXJlsMmqTwIGDaOA3dZyZXeXCRrBdu39FlpaRHvqqLKExeajZxzCdYa IvRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MaR9br3N; 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 i3si3200553ejr.178.2021.05.20.09.39.52; Thu, 20 May 2021 09:40:17 -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=MaR9br3N; 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 S233357AbhETJmS (ORCPT + 99 others); Thu, 20 May 2021 05:42:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:40918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233502AbhETJjb (ORCPT ); Thu, 20 May 2021 05:39:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1D84A61432; Thu, 20 May 2021 09:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503084; bh=OGZPhf9AAnvplo3tk4SDgZ6m8WAY3wshvN3+bs/qWjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MaR9br3N4lb5X3TYYOOD0KrJ8tk+tAotGMpODxZ2ZBZtfPoMKsmrBjION2riG8ZXQ 6V3Ou2vWoNkc5cg+AVwm4uPCqDnOQ0QqClJdKIDUgTk7Zzeifyz+doz6oed5i5olL9 PRhXnSltd956LjxpueMyNqBeVcYOutu/2Vqp4NQY= 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 4.19 061/425] media: tc358743: fix possible use-after-free in tc358743_remove() Date: Thu, 20 May 2021 11:17:10 +0200 Message-Id: <20210520092133.444957044@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 d9bc3851bf63..041b16965b96 100644 --- a/drivers/media/i2c/tc358743.c +++ b/drivers/media/i2c/tc358743.c @@ -2192,7 +2192,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