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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 19FD3C43603 for ; Tue, 10 Dec 2019 21:23:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D759B206D5 for ; Tue, 10 Dec 2019 21:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576013023; bh=li3AXOeVeqlc3Mu6jNuhxf5fIXOLBal++8saYuL420A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1Sl1BDblfAT+JqucNIMoarevrm6hweK+4UCc87UW5XWBsUoX1g5vx89Ijgxs6Xlxh z9wsXeK4pmUmvmx3UtvTa+LIBMA9p5UJ3n+dFNjP5AXgdacpFBJePcbKWcNodBD06s IfAzgNzmY5KIXTSNE3dR6oIgwMatZDPAB/8Xe3JI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728916AbfLJVXl (ORCPT ); Tue, 10 Dec 2019 16:23:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:33518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728695AbfLJVLI (ORCPT ); Tue, 10 Dec 2019 16:11:08 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8221D246AA; Tue, 10 Dec 2019 21:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576012268; bh=li3AXOeVeqlc3Mu6jNuhxf5fIXOLBal++8saYuL420A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ypvaqbR7xqerglIGe3qGdGJt5rHzijUprk8Q6mFqZhISkDt9JwMo4a0Aof8autJtS B5V1snjUpxtC2tZ9OIUaMBXCyz3cqXxNwWlzCNe3IDQ06k7XW3vzx5VbKvVyDwFBXx YrYVWLXETuJF+XsierHEerueZcQEpsTHwdSFsmKM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pan Bian , Mark Brown , Sasha Levin , linux-spi@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 213/350] spi: img-spfi: fix potential double release Date: Tue, 10 Dec 2019 16:05:18 -0500 Message-Id: <20191210210735.9077-174-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191210210735.9077-1-sashal@kernel.org> References: <20191210210735.9077-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pan Bian [ Upstream commit e9a8ba9769a0e354341bc6cc01b98aadcea1dfe9 ] The channels spfi->tx_ch and spfi->rx_ch are not set to NULL after they are released. As a result, they will be released again, either on the error handling branch in the same function or in the corresponding remove function, i.e. img_spfi_remove(). This patch fixes the bug by setting the two members to NULL. Signed-off-by: Pan Bian Link: https://lore.kernel.org/r/1573007769-20131-1-git-send-email-bianpan2016@163.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-img-spfi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c index 439b01e4a2c8d..f4a8f470aecc2 100644 --- a/drivers/spi/spi-img-spfi.c +++ b/drivers/spi/spi-img-spfi.c @@ -673,6 +673,8 @@ static int img_spfi_probe(struct platform_device *pdev) dma_release_channel(spfi->tx_ch); if (spfi->rx_ch) dma_release_channel(spfi->rx_ch); + spfi->tx_ch = NULL; + spfi->rx_ch = NULL; dev_warn(spfi->dev, "Failed to get DMA channels, falling back to PIO mode\n"); } else { master->dma_tx = spfi->tx_ch; -- 2.20.1