Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp413260pxj; Thu, 20 May 2021 12:14:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF9Bv/bclLWeL/Alx6Sast2QomgOWaJxqpctu6Nt1XzhukW9rEz/5LTr2fH9dtympg1mqm X-Received: by 2002:a17:907:1ca1:: with SMTP id nb33mr6182918ejc.75.1621538063527; Thu, 20 May 2021 12:14:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538063; cv=none; d=google.com; s=arc-20160816; b=H751xn/tMGGY6DNH2dcFf4NTXbu97FgUF5VhTbpzygdEq7RRZALeWkN+67CR/lf3NO ttaQySi6M3brZ8hcwZv1YoIN210pEhJGILZ3ngmro9K1tDaRRBcNos8h3AA4nnFLSSDc ZCiJzj+j3rpryWz0zgsRFYe4O/nqUrP6CqAa03AcztSyrPo6UuzwHD2FLmC342LU2AA4 sPm2o7a8tPE8PqCt3BttWel3eHeIlg2zQbrjSM0JiPn44f4yKDsYcRO4Vyvz8Qm+1Dwh KrhnWkAxmc2RojGAPba0JggkPp8misNAjTfsLBicu6KeAolP7ECyT34NgSknrVBQmULw e5PQ== 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=8a7M1IKlStGRTGvzB7l4zztdLk0vYa9QaW0Au3o6LoI=; b=mDupNh8izGUQN2AlNeJh9wKfMGXm1ghD8yuQr8eTpQzOR9zBBsxTr9P/Gx1J9YM2Vc BbX6+K33mnePZOWzCq69qppyyTYW8uciuyKCLFJ2MHuS9lyadqvuYTB08AETcDsNt1De WceBqAgrlA5YA08qV85CoZKcIITNPFMfctJZHB09n53H8/hzCXNvRc2RSpCAZV4K5YKl V77Xk2F08pvj2A+lB+vJGbJV68/XLTSUQ2MxAvHZvKfklih05YhLbCyvRRbwS8+edEy/ Rrk21bwxRSzGzenegnZup71ow+Ytb97vZVxtGxx4qImnsJYqyGqfblLOwW/WqefZEu5b cD+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ycQYUuJV; 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 ss5si3649430ejb.294.2021.05.20.12.14.00; Thu, 20 May 2021 12:14:23 -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=ycQYUuJV; 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 S237148AbhETKc5 (ORCPT + 99 others); Thu, 20 May 2021 06:32:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:52000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236389AbhETKTb (ORCPT ); Thu, 20 May 2021 06:19:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4DD02619B9; Thu, 20 May 2021 09:47:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504031; bh=1xHvd1vg/suJBGNxxzClRs3R8asIGh7BF20ZXBq74mo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ycQYUuJVYGJ4QUtMQYBBUIQAOXkmBUg/+EjWnnmg7pT7IKxoylJbWQlaa86VnpN5s wllqsOR+wxTs0wL6x3OLdH6zke0vT3JD/bbPZfc39p8GcNetiLdJXkgLGH6bzqYxo9 DoWWUilKFWcl55zYU6GcWREgh7BZ/cjJdJfR186E= 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.14 064/323] media: i2c: adv7511-v4l2: fix possible use-after-free in adv7511_remove() Date: Thu, 20 May 2021 11:19:16 +0200 Message-Id: <20210520092122.303012230@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 ef1144668809..2148a29909e0 100644 --- a/drivers/media/i2c/adv7511-v4l2.c +++ b/drivers/media/i2c/adv7511-v4l2.c @@ -1976,7 +1976,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); if (state->i2c_cec) i2c_unregister_device(state->i2c_cec); -- 2.30.2