Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1049532pxb; Tue, 17 Aug 2021 02:31:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOoXKMhA9+ga190wMonmjQs1+vV0mgf4YgvXD3SKjkPHiHDfvIdpGpNrVrj3PlYFICbzFY X-Received: by 2002:a05:6e02:12b3:: with SMTP id f19mr1830869ilr.234.1629192676717; Tue, 17 Aug 2021 02:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629192676; cv=none; d=google.com; s=arc-20160816; b=tcAoM1b6jiR4ISkECTmKTBwVrxii4kRc2qamdDzdFd61MV+ImEn9WFdjMlSzjsqmGd eajoeQdEuEVAQZjk0yLHk/BW/AlM+tLnFrgN93mRkfkvBkc1S3D1vRpDcl/YhgNBuG08 xMbHEOPi4y7s6ZtDm8yJRaXZHfvRTOrIAkVRUTBp+TuHvmLPJlReIKPjP2BNSYeNeAsA 2tu8bs1XqBiywDLUSz7/kPsJeuwBvIzJjgciUXJreHjDCNq2LnscDxP+ii1V9Qn2iive PiXUKrK3KNIiaUOUglFav4MQ0ZViJiiEa9k1qxz038H2jYT2ElrAVtn6TCfwtYlXiSL7 xUDQ== 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 :message-id:date:subject:cc:to:from; bh=q/Xi69uWD8NhFXpLhzpgpShKVCEReJzaZhuwgyYilpI=; b=dMQY9XsJWO7FOz0tfdiPksWKyGQnpSNGfuYZH0HqG/HLSCrw2zahH4uNcnby/o4f3I VSzslThg5SUxlp1Dcd+dldYMEqVeQpxEOMqbM5FJ0Y3BlMWekUNBcyCAitBBWbyCQGXx 460eJl4uwyzuFy1A/ts4KHoWpe0ub091qMz+w3G/9mo4yaSlOJTDpPN0EwV/uKivllcN 58uY8dcTxQFWrKtPBoGJeGsrfS5EPuwbuqORwTb1ZkELWv4V/MW/cEGcfX4pwvgmo0X3 iuh1cR/gB9cVEbYTlkX+xDqZcANLfxh8kTjlzQIpZDRNB9MpdDtZj3ThV5mm8Ih4fGEV rSFw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si2139051ioo.37.2021.08.17.02.31.05; Tue, 17 Aug 2021 02:31:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239748AbhHQJaS (ORCPT + 99 others); Tue, 17 Aug 2021 05:30:18 -0400 Received: from mail.ispras.ru ([83.149.199.84]:51274 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239545AbhHQJaF (ORCPT ); Tue, 17 Aug 2021 05:30:05 -0400 Received: from hellwig.intra.ispras.ru (unknown [10.10.2.182]) by mail.ispras.ru (Postfix) with ESMTPS id 3BED740D4004; Tue, 17 Aug 2021 09:29:31 +0000 (UTC) From: Evgeny Novikov To: Miquel Raynal Cc: Evgeny Novikov , Richard Weinberger , Vignesh Raghavendra , Ramuthevar Vadivel Murugan , Martin Blumenstingl , Christophe JAILLET , Kirill Shilimanov , Anton Vasilyev , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org, stable@vger.kernel.org Subject: [PATCH v2] mtd: rawnand: intel: Fix error handling in probe Date: Tue, 17 Aug 2021 12:29:30 +0300 Message-Id: <20210817092930.23040-1-novikov@ispras.ru> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ebu_nand_probe() did not invoke ebu_dma_cleanup() and clk_disable_unprepare() on some error handling paths. The patch fixes that. Found by Linux Driver Verification project (linuxtesting.org). Fixes: 0b1039f016e8 ("mtd: rawnand: Add NAND controller support on Intel LGM SoC") Signed-off-by: Evgeny Novikov Co-developed-by: Kirill Shilimanov Signed-off-by: Kirill Shilimanov Co-developed-by: Anton Vasilyev Signed-off-by: Anton Vasilyev Cc: stable@vger.kernel.org --- v2: Fix remarks from Miquel Raynal: - Add a Fixes: tag. - Add a Cc: stable tag. --- drivers/mtd/nand/raw/intel-nand-controller.c | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/raw/intel-nand-controller.c b/drivers/mtd/nand/raw/intel-nand-controller.c index 8b49fd56cf96..29e8a546dcd6 100644 --- a/drivers/mtd/nand/raw/intel-nand-controller.c +++ b/drivers/mtd/nand/raw/intel-nand-controller.c @@ -631,19 +631,26 @@ static int ebu_nand_probe(struct platform_device *pdev) ebu_host->clk_rate = clk_get_rate(ebu_host->clk); ebu_host->dma_tx = dma_request_chan(dev, "tx"); - if (IS_ERR(ebu_host->dma_tx)) - return dev_err_probe(dev, PTR_ERR(ebu_host->dma_tx), - "failed to request DMA tx chan!.\n"); + if (IS_ERR(ebu_host->dma_tx)) { + ret = dev_err_probe(dev, PTR_ERR(ebu_host->dma_tx), + "failed to request DMA tx chan!.\n"); + goto err_disable_unprepare_clk; + } ebu_host->dma_rx = dma_request_chan(dev, "rx"); - if (IS_ERR(ebu_host->dma_rx)) - return dev_err_probe(dev, PTR_ERR(ebu_host->dma_rx), - "failed to request DMA rx chan!.\n"); + if (IS_ERR(ebu_host->dma_rx)) { + ret = dev_err_probe(dev, PTR_ERR(ebu_host->dma_rx), + "failed to request DMA rx chan!.\n"); + ebu_host->dma_rx = NULL; + goto err_cleanup_dma; + } resname = devm_kasprintf(dev, GFP_KERNEL, "addr_sel%d", cs); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, resname); - if (!res) - return -EINVAL; + if (!res) { + ret = -EINVAL; + goto err_cleanup_dma; + } ebu_host->cs[cs].addr_sel = res->start; writel(ebu_host->cs[cs].addr_sel | EBU_ADDR_MASK(5) | EBU_ADDR_SEL_REGEN, ebu_host->ebu + EBU_ADDR_SEL(cs)); @@ -653,7 +660,8 @@ static int ebu_nand_probe(struct platform_device *pdev) mtd = nand_to_mtd(&ebu_host->chip); if (!mtd->name) { dev_err(ebu_host->dev, "NAND label property is mandatory\n"); - return -EINVAL; + ret = -EINVAL; + goto err_cleanup_dma; } mtd->dev.parent = dev; @@ -681,6 +689,7 @@ static int ebu_nand_probe(struct platform_device *pdev) nand_cleanup(&ebu_host->chip); err_cleanup_dma: ebu_dma_cleanup(ebu_host); +err_disable_unprepare_clk: clk_disable_unprepare(ebu_host->clk); return ret; -- 2.26.2