Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp60586pxj; Thu, 20 May 2021 04:35:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJye0PVF5lTggsUwQhWQZI83fbgOVlGD3xLsrFKA3GvMCnp5MZpCJRYtGAy9nIyfPWnHQE60 X-Received: by 2002:aa7:d843:: with SMTP id f3mr4483761eds.270.1621510500769; Thu, 20 May 2021 04:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621510500; cv=none; d=google.com; s=arc-20160816; b=uNYJcVq6ZUHSgPzuMFbO8T28SbeOEKBSsbzEWvCuUx1b7xmxLRYbV58nV6Z8idtJOt 1AUf9mmXcj+3+egOYMxzRa/6aWA00lN5xKePIRrih+rBpv8IeWX9xaGrP6paa29qIAPF 1rG38/fW3IT+VfI1031LUfVjVjZ1LLSWxIlKuGxZz4EM2IOjQO1uy9pU6tZUIV3UsRKv IeexaLpeI1OYAvQxvCawnvKGMW2ll45+g8xMdrR85Fht3EONmebN9sZiyO4BUeTujPAz Pe2dHBn7G7/u7xiuVzNt1xAlSoNdzNNfw7OtDutfY7Q4OrrA5Nyw5RENQVb+QU2Ot/Jo 5X8Q== 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=/d6hadmxS3JmYobKQWq3DBdDk9/lfeJPD+r/vJPH6NQ=; b=v9/VvHjTcEyxSkOSGCrAD2R1k3Y+BK6B5N9p1Jwtfo6bOYJtJORmRXPKC5/KBtQqhz 6O5NPLMu3KLmSFoQJfcXlY5Bw7p+tL/d0iOAJhZh6c37YrMDsGon7FnJRdSmhHJ6PS6d YwvEciLnJvjHn7zEwMnfptVtjePURxvO2lHEXzNEB2D+jN50K1/lqKfcbPBE8kqwT2uH ua07XD157+BHJ8doFor6XAlW2LCPba2j0UwpPc14mET8/UiTD6PJxkdulRFfRGFy2WJI kR3fqZ3CfZX5gJbpVB7SSe8MK8qjMY3YimkfI8kncdPnzKQ9x75zZ2In7/0HC9M8dyKF l/sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zo//Dapw"; 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 ay17si2772888ejb.496.2021.05.20.04.34.36; Thu, 20 May 2021 04:35:00 -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="zo//Dapw"; 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 S241404AbhETLaQ (ORCPT + 99 others); Thu, 20 May 2021 07:30:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:56412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240371AbhETLKC (ORCPT ); Thu, 20 May 2021 07:10:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E885C61D3C; Thu, 20 May 2021 10:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505214; bh=o2t2W2YyIFJIlQucS6TNKdg6QFtpsMeIboeh/CYstVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zo//Dapw9Hq0vObYl5dgPrq/LxG2dcRBbmaZ9jiQY+H6kEpvHDYcfkgQiC8y6XQKs An+NR9F8tH2UEdiJKIpV3KFQPqSRLOCJnmVDwYdxsznIVoi23/cuit/mY/1RYA0b0Q ixySHvyOu9OJ7nH0TKSGzShrYgtvrzlq+y9f40e8= 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.4 032/190] media: i2c: adv7511-v4l2: fix possible use-after-free in adv7511_remove() Date: Thu, 20 May 2021 11:21:36 +0200 Message-Id: <20210520092103.235976740@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 b35400e4e9af..e85777dfe81d 100644 --- a/drivers/media/i2c/adv7511-v4l2.c +++ b/drivers/media/i2c/adv7511-v4l2.c @@ -1570,7 +1570,7 @@ static int adv7511_remove(struct i2c_client *client) client->addr << 1, client->adapter->name); 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_pktmem); destroy_workqueue(state->work_queue); -- 2.30.2