From patchwork Fri Jan 24 09:28:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 233223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CECEBC2D0DB for ; Fri, 24 Jan 2020 09:50:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A48EB206D5 for ; Fri, 24 Jan 2020 09:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579859453; bh=eh2L1NasMeqOmYUwFN8uqSQZZoycQzz+pBTc+u6CabY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EkvoxNCeHhVbM7IqbUJBIDEsIh0EwSML/lVhvKr9hlcCtyL7sxdmJy1tGg8Jnr4tj Sz0haDupbLiRse4Cvd5VYn8VO6VGWd5xy3Ugrl/9pqkcPcUZ3rP7gMdhb4EKvB0vCV GSXOKMBeY/ecrrci9PmCpVNXPigupA8bKfY9pnNg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387568AbgAXJux (ORCPT ); Fri, 24 Jan 2020 04:50:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:51778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730713AbgAXJuw (ORCPT ); Fri, 24 Jan 2020 04:50:52 -0500 Received: from localhost (unknown [145.15.244.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE65F208C4; Fri, 24 Jan 2020 09:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579859452; bh=eh2L1NasMeqOmYUwFN8uqSQZZoycQzz+pBTc+u6CabY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j7MofLFUCqLpr5rHt6YolRhXerCHxQWPDWJWPlwn1HvXDUY33uyDdTLkaWiVLtZGw uM16Fr+F7/wnZ2IahTz4bGyZwSpxNihLVIOxSz0CLEImVbqECjQVfGNgMhjvwAET1i Eh/nEggkIyoJIXfT76ATZI2EtXH6ZCxdHCOAjUaU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Lindgren , Bin Liu , Sven Van Asbroeck , Felipe Balbi , Sasha Levin Subject: [PATCH 4.14 105/343] usb: phy: twl6030-usb: fix possible use-after-free on remove Date: Fri, 24 Jan 2020 10:28:43 +0100 Message-Id: <20200124092933.908821373@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124092919.490687572@linuxfoundation.org> References: <20200124092919.490687572@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sven Van Asbroeck [ Upstream commit 5895d311d28f2605e2f71c1a3e043ed38f3ac9d2 ] In remove(), use cancel_delayed_work_sync() to cancel the delayed work. Otherwise there's a chance that this work will continue to run until after the device has been removed. This issue was detected with the help of Coccinelle. Cc: Tony Lindgren Cc: Bin Liu Fixes: b6a619a883c3 ("usb: phy: Check initial state for twl6030") Signed-off-by: Sven Van Asbroeck Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/phy/phy-twl6030-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c index b5dc077ed7d3c..8e14fa2211912 100644 --- a/drivers/usb/phy/phy-twl6030-usb.c +++ b/drivers/usb/phy/phy-twl6030-usb.c @@ -413,7 +413,7 @@ static int twl6030_usb_remove(struct platform_device *pdev) { struct twl6030_usb *twl = platform_get_drvdata(pdev); - cancel_delayed_work(&twl->get_status_work); + cancel_delayed_work_sync(&twl->get_status_work); twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, REG_INT_MSK_LINE_C); twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK,