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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17A7AC433F5 for ; Fri, 20 May 2022 16:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351905AbiETQxX (ORCPT ); Fri, 20 May 2022 12:53:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346045AbiETQxT (ORCPT ); Fri, 20 May 2022 12:53:19 -0400 Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr [80.12.242.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5EB5149162 for ; Fri, 20 May 2022 09:53:17 -0700 (PDT) Received: from [192.168.1.18] ([86.243.180.246]) by smtp.orange.fr with ESMTPA id s5sEnGEDBYaC7s5sEnOR8j; Fri, 20 May 2022 18:53:16 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Fri, 20 May 2022 18:53:16 +0200 X-ME-IP: 86.243.180.246 Message-ID: <7b1b26e4-cc8e-3375-788c-56b5b548367d@wanadoo.fr> Date: Fri, 20 May 2022 18:53:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v2] mtd: rawnand: cafe: fix drivers probe/remove methods Content-Language: en-GB To: Peng Wu , miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, liwei391@huawei.com, Kernel Janitors References: <20220520084425.116686-1-wupeng58@huawei.com> From: Christophe JAILLET In-Reply-To: <20220520084425.116686-1-wupeng58@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 20/05/2022 à 10:44, Peng Wu a écrit : > Driver should call pci_disable_device() if it returns from > cafe_nand_probe() with error. > > Meanwhile, the driver calls pci_enable_device() in > cafe_nand_probe(), but never calls pci_disable_device() > during removal. > > Signed-off-by: Peng Wu > --- > v2: > - fix the subject prefix with "mtd: ranwnand: cafe:" > --- > drivers/mtd/nand/raw/cafe_nand.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c > index 9dbf031716a6..af119e376352 100644 > --- a/drivers/mtd/nand/raw/cafe_nand.c > +++ b/drivers/mtd/nand/raw/cafe_nand.c > @@ -679,8 +679,10 @@ static int cafe_nand_probe(struct pci_dev *pdev, > pci_set_master(pdev); > > cafe = kzalloc(sizeof(*cafe), GFP_KERNEL); > - if (!cafe) > - return -ENOMEM; > + if (!cafe) { > + err = -ENOMEM; > + goto out_disable_device; > + } > > mtd = nand_to_mtd(&cafe->nand); > mtd->dev.parent = &pdev->dev; > @@ -801,6 +803,8 @@ static int cafe_nand_probe(struct pci_dev *pdev, > pci_iounmap(pdev, cafe->mmio); > out_free_mtd: > kfree(cafe); > + out_disable_device: > + pci_disable_device(pdev); > out: > return err; > } > @@ -822,6 +826,7 @@ static void cafe_nand_remove(struct pci_dev *pdev) > pci_iounmap(pdev, cafe->mmio); > dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); Hi, Not related to this patch , but I wonder if this dma_free_coherent() is needed. It is already part of cafe_nand_detach_chip() which is a .detach_chip() function. Is this .detach_chip() function already called (by nand_cleanup()) somewhere in the removal process? CJ > kfree(cafe); > + pci_disable_device(pdev); > } > > static const struct pci_device_id cafe_nand_tbl[] = {