Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2484555pxj; Mon, 10 May 2021 04:12:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIczDthD15odolunI9pHaR9mCq1UF0SXVsxQ1UIaxHXgU3GGSpv/I/aBL6Qkap0lWjn8Ud X-Received: by 2002:a02:bb0d:: with SMTP id y13mr20968549jan.124.1620645063318; Mon, 10 May 2021 04:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645063; cv=none; d=google.com; s=arc-20160816; b=KN61wzZkTthIvrJaNs0dEWjReTJRr1DO6T+mtYPqxpvK2hqXA21s1TNyqduE2LHWQc ChwFBBM3IbGQ/Z6/PYJe3yZ7wFN3tbIbTiOzZQCmiY0TZAFbw3x6PezKIcOIpdIhiOJI rb2phr1/hGETY2adA5DZPKMsB/t4b7jupFdH9wPUEtFnddPSPSy4z27+jYSwhJIM1cup dN0paQsDe0rIkIccd67nuGDamS2r9vS3a2vkcr4uZRm1MCGfdW35zhP0uAluOMWOlCn0 jh6ylS2SvBove5+tdIvvCC1x/bGnrawcYVE8vGkPonkRhh/lnYE3FZS/zTsElfs7D5fc rxag== 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=xEbn2ZC3iWtkL6G8S7VqTsJKKIHTmVjxc+0ryABFHtU=; b=AWlhREcbMO1/DfhwUpi0BzuHcdah9E9dxhNQrKdlJvi/K3IZtMgwcywb1tEJH4WkhI 02e5sjRHZskoodlL4R0MZqG72cXLim1jK+8wsB0NdCTg9Xwx8M7mpZ6k/XfOlxILY+qe reINPtCftPJyzjFKZaLGTkxyXmCTJbs73Bj3M/VGL4s3U5rPhVR6W7ZJ2Q6W7qv+XXBe 12QHn5v+0r6UFYvPqxnq7R/dE24qmK+NkibD1s2ATx1jxLzRLEd3cduMiRcjQ0G60jiZ 8XO1B/L4KgE5y7bRZwjKxhRn2fbM0yiYjid3DOq6+J/YYllPUMuvy/Y1kotlQt9qAjeJ Ct5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CN4nEvgZ; 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 z8si15877575ilh.46.2021.05.10.04.10.50; Mon, 10 May 2021 04:11:03 -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=CN4nEvgZ; 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 S233393AbhEJLIm (ORCPT + 99 others); Mon, 10 May 2021 07:08:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:59360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232808AbhEJKtN (ORCPT ); Mon, 10 May 2021 06:49:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 27A0761945; Mon, 10 May 2021 10:38:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643091; bh=pU1oLEmc3srbrCE9Upsp4U+CnxLdLR9A6RqOKkFg6tI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CN4nEvgZo+53FPguvQvnpZ1k+0T32SCzAJ6BZBFxCc01yAjkkzmWAjulN+3n0iDqf WXE/vK+eJkQFuL+YeqN3jUGsKhVJ7g5UH6ngE8slv3rJ8QMetlq2Vj4RdO3W9ZsCRC EZXSYZBVZWZZr98EGej6CELApQQh+E1TqTdpu99k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yang Yingliang , Krzysztof Kozlowski , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.10 175/299] power: supply: s3c_adc_battery: fix possible use-after-free in s3c_adc_bat_remove() Date: Mon, 10 May 2021 12:19:32 +0200 Message-Id: <20210510102010.740899346@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 68ae256945d2abe9036a7b68af4cc65aff79d5b7 ] 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 Reviewed-by: Krzysztof Kozlowski Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/s3c_adc_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/s3c_adc_battery.c b/drivers/power/supply/s3c_adc_battery.c index 60b7f41ab063..ff46bcf5db01 100644 --- a/drivers/power/supply/s3c_adc_battery.c +++ b/drivers/power/supply/s3c_adc_battery.c @@ -394,7 +394,7 @@ static int s3c_adc_bat_remove(struct platform_device *pdev) gpio_free(pdata->gpio_charge_finished); } - cancel_delayed_work(&bat_work); + cancel_delayed_work_sync(&bat_work); if (pdata->exit) pdata->exit(); -- 2.30.2