Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2474535pxj; Mon, 10 May 2021 04:00:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG4ISlE+1XE3FxoFACq2O7SVPeTyFhxcJT+6ieltL7RQFxy8HvH3wl8iC1vd/z4yur1MzC X-Received: by 2002:a05:6e02:f42:: with SMTP id y2mr9558675ilj.216.1620644451637; Mon, 10 May 2021 04:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644451; cv=none; d=google.com; s=arc-20160816; b=n/oXLLeAGJ9gI0dqr3lEH//HQ682l6lctPSytzUNoDPIclHrhDXbCxuFzPje9yrjwL STUCfr7l71m00gl2ervltD6S0R8+42OYPcbG6Ar3e+H9VIQis8feiMqRfR8rGZb2ik/0 pqDX2YrFeRduJfebYy/+qFKVwl1xI9fSjovZK+bTJ2nGGf+KlMsENBJIFjjqTDBQf+ky tggw45GH9tgZ5+M9XEIr1IFO4tOjvvJltd8TKLoSpKSGLi4hBemLNXMKgqghPYJesPqQ 64hEYuiB9j3mppUIQR7LCePnm/rbu1nQNtqi/xIOThu6e3dNmEROstwIdIaFT7hpvzVP wDrA== 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=UXcw+8uvwwDQbbmp4s0aBQ7W9CCY28cu+33GSnbABXU=; b=mjOSXmmRg8Wi0Wv/E5ckwMf7j+ZXbirQVOeLFa4AgAjuzezijGzcNmvifiJcAiuktH SyVfoWFFnxc4Dczf6R5gINgHB5UoUe74BfYarTxHHaLxaLG5KQbo4tw3pSHVMtvrErGo FoJa+kNafo9+E6qlsQ/6CAWPM8WFw6xRjI7IgG+ytyDZvYcAE6mqCzF8x9MT49Ofd3iv GXjSk9M8JyYNRS+B37JJU2NedhsQk8xCbj7aM2SD+OE0LpUocpskqIxNZgZCuD19J/Ct /BUskhs+WR6l+SLlAKgoL22yrl1IooRBrBtLwGYD0Sl9zM58yYqsQ3QkAiYrGU0mdmY5 MRIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Jmb5/z53"; 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 n6si17896516ilk.9.2021.05.10.04.00.39; Mon, 10 May 2021 04:00:51 -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="Jmb5/z53"; 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 S231508AbhEJK5s (ORCPT + 99 others); Mon, 10 May 2021 06:57:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:59424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233170AbhEJKpQ (ORCPT ); Mon, 10 May 2021 06:45:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EAE6361482; Mon, 10 May 2021 10:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642909; bh=s++pOuEuj5uVGNpgdbWGjOD4K3Kud/91J//OAfiA/aw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jmb5/z53PrILbgcJ5HCXnFLIJkkmFT75XhmVl3McM7BfxGYVuqlXZ/ZycSmJc+3XD HOWVC00RKpPrUlM6wvLEH+1KMUpLXINCwFbmaXewlsJzi3Yc9I5LBMK/HvT9+uoVIC pRHohN2rLBlBmEq4c1e5nINxawKtTsuPIWtXPdPQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yang Yingliang , Vinod Koul , Sasha Levin Subject: [PATCH 5.10 101/299] phy: phy-twl4030-usb: Fix possible use-after-free in twl4030_usb_remove() Date: Mon, 10 May 2021 12:18:18 +0200 Message-Id: <20210510102008.269232224@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 e1723d8b87b73ab363256e7ca3af3ddb75855680 ] 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 Link: https://lore.kernel.org/r/20210407092716.3270248-1-yangyingliang@huawei.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/phy/ti/phy-twl4030-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/ti/phy-twl4030-usb.c b/drivers/phy/ti/phy-twl4030-usb.c index 9887f908f540..812e5409d359 100644 --- a/drivers/phy/ti/phy-twl4030-usb.c +++ b/drivers/phy/ti/phy-twl4030-usb.c @@ -779,7 +779,7 @@ static int twl4030_usb_remove(struct platform_device *pdev) usb_remove_phy(&twl->phy); pm_runtime_get_sync(twl->dev); - cancel_delayed_work(&twl->id_workaround_work); + cancel_delayed_work_sync(&twl->id_workaround_work); device_remove_file(twl->dev, &dev_attr_vbus); /* set transceiver mode to power on defaults */ -- 2.30.2