Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2488166pxj; Mon, 10 May 2021 04:18:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIQv/iWUc52eUBm9EY65D5+n+5++LccncbQq6D4FA7msh+7H4S0AMwtADD695R/NFVb9b2 X-Received: by 2002:a17:906:f210:: with SMTP id gt16mr24986928ejb.52.1620645519707; Mon, 10 May 2021 04:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645519; cv=none; d=google.com; s=arc-20160816; b=djvYkJDwnkZ+xkFXDENkc8JEXj3l/c9qFuUiyCUd65RGINEwYIxNVi7IdUv8437Ulq sFKiGbYqkIybyFxxa6CjISI5DvXYDGXneJH858LhYFK7AnU2CUn72cXXa9dQGfSJhax3 87kM5cKPdNHl7Ag93FqAdrk1cZlhZDwWG27+OtQ8uPWMKSEaELvbdHiS+zzKhYdWi6RC XtXa12PjufhFhm+lSNfAwpF99UNaND02Q415K7M0+VJ5ScOiP3EfR22EGjViCPwkxjuQ 92V8PSxiHUfEp9/zP319/x9GSOuL0Y9IX59bynCLAZzzW50ABYcwqBzrLjxp12N3MTLg grUQ== 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=GGNUPHnVg41zb8+r4hjsQrRAqADesB82CBXJNykj+oo=; b=VqmgIK5cWR8Tp5Q5T9bbZp3Lsq44AWUi3BgIIi6Xl7to1NtZJAkU9oG8Y9kxNIVA3m gdkgm5xihvbl03gjTPen4u0DMB1p/+5DWRmm4J3wfF8eaRPFz2GiFLyJo/picSGBjbW8 BPepyYB0o4s7796bSBwM/XYmaZycmqg10m7qdgSp5BO1+pc9YtnxhfGKs8Ll+SF/xNsp 1IauT/AEHDZlmpPadVxalP0adHF5YMMvvpYb1mU5rDYohRGgzP3EeDXZ9p0A4OKomSyM uHsIr9BiOF0+yyxlLOoxvcooakdEwfx8vZBv+ZMXYeZHabv0Uikbq+l5eHDabjpGrMlb BkHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e8Roq9h7; 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 t16si13655083eji.432.2021.05.10.04.18.15; Mon, 10 May 2021 04:18:39 -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=e8Roq9h7; 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 S236792AbhEJLK1 (ORCPT + 99 others); Mon, 10 May 2021 07:10:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:41454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233167AbhEJKtl (ORCPT ); Mon, 10 May 2021 06:49:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BF0AA6145C; Mon, 10 May 2021 10:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643101; bh=TbnfRyrVPiZhBN1/T3YrOQ5IbnGguP1qyaLCMaCnOYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e8Roq9h7wsky3RndkjBRBr1usU3beJiYaWzxVR9fx0dr3DeHhzqXgOC3jib4xTvMu i84jb/r5KWNsn35aKWo+FgLX4ctX8kl2qGTgQifxzGb/SbBZrSGywNrCCfWRzRv5ks hCDy4bcPF2CKeJcSe5HF419JZLUSWSX9mpMi9jXU= 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 178/299] media: i2c: adv7511-v4l2: fix possible use-after-free in adv7511_remove() Date: Mon, 10 May 2021 12:19:35 +0200 Message-Id: <20210510102010.839621294@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 2c9541720c66899adf6f3600984cf3ef151295ad ] 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/adv7511-v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/adv7511-v4l2.c b/drivers/media/i2c/adv7511-v4l2.c index a3161d709015..ab7883cff8b2 100644 --- a/drivers/media/i2c/adv7511-v4l2.c +++ b/drivers/media/i2c/adv7511-v4l2.c @@ -1964,7 +1964,7 @@ static int adv7511_remove(struct i2c_client *client) adv7511_set_isr(sd, false); adv7511_init_setup(sd); - cancel_delayed_work(&state->edid_handler); + cancel_delayed_work_sync(&state->edid_handler); i2c_unregister_device(state->i2c_edid); i2c_unregister_device(state->i2c_cec); i2c_unregister_device(state->i2c_pktmem); -- 2.30.2