From mboxrd@z Thu Jan 1 00:00:00 1970 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.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,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 C2941C04E53 for ; Wed, 15 May 2019 11:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B3FC20881 for ; Wed, 15 May 2019 11:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918868; bh=IQiKbuEWVm4f7lw5bzZBPzwaZrsJiLU5nh71iDFy38o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SM4wPfTlzur7f66EiuSm+wVDRIlnv9+Y2qoNpZqYuRAmultyDLWgqqmvScTLfuggs xfEJDCcwEo+JuF89cqjdBPG/EtM2ROOUosuhEMWxogYEa564Jak8UEgDKjI2DCR4s+ 2wcHECynPwzNdJnJbqx3GJa1hUD+oXPHyXCJvqC0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730143AbfEOLO1 (ORCPT ); Wed, 15 May 2019 07:14:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:50524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730139AbfEOLO1 (ORCPT ); Wed, 15 May 2019 07:14:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 0965C20862; Wed, 15 May 2019 11:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918866; bh=IQiKbuEWVm4f7lw5bzZBPzwaZrsJiLU5nh71iDFy38o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ozho1urFN/HrG/xNNu2+EKrOBC4RYKuuJJj2t99puA+KoJ1Owlj+6cNUtu4F++phW eD9sOFmusfXmz+cKhGIYjsvQXVgo+LZ/TCCGunfW5LTqRQa4SqOpOtsVtMF8H3YYqA Tfq+2f2F9e3D5h+vZt+rst/iz12uPjzTMRDM9sbE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Van Asbroeck , Jonathan Cameron , Sasha Levin Subject: [PATCH 4.9 06/51] iio: adc: xilinx: fix potential use-after-free on remove Date: Wed, 15 May 2019 12:55:41 +0200 Message-Id: <20190515090619.305087626@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090616.669619870@linuxfoundation.org> References: <20190515090616.669619870@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit 62039b6aef63380ba7a37c113bbaeee8a55c5342 ] When cancel_delayed_work() returns, the delayed work may still be running. This means that the core could potentially free the private structure (struct xadc) while the delayed work is still using it. This is a potential use-after-free. Fix by calling cancel_delayed_work_sync(), which waits for any residual work to finish before returning. Signed-off-by: Sven Van Asbroeck Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/xilinx-xadc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index 56cf5907a5f01..143894a315d9b 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -1299,7 +1299,7 @@ static int xadc_remove(struct platform_device *pdev) } free_irq(irq, indio_dev); clk_disable_unprepare(xadc->clk); - cancel_delayed_work(&xadc->zynq_unmask_work); + cancel_delayed_work_sync(&xadc->zynq_unmask_work); kfree(xadc->data); kfree(indio_dev->channels); -- 2.20.1