Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756939AbdLVV51 (ORCPT ); Fri, 22 Dec 2017 16:57:27 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:60004 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756636AbdLVV50 (ORCPT ); Fri, 22 Dec 2017 16:57:26 -0500 Date: Fri, 22 Dec 2017 22:57:24 +0100 From: Boris Brezillon To: Alexey Khoroshilov Cc: Stefan Agner , Richard Weinberger , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: Re: [PATCH] mtd: nand: vf610: fix error handling in vf610_nfc_probe() Message-ID: <20171222225724.1e26bc38@bbrezillon> In-Reply-To: <1513978994-5739-1-git-send-email-khoroshilov@ispras.ru> References: <1513978994-5739-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1024 Lines: 32 On Sat, 23 Dec 2017 00:43:14 +0300 Alexey Khoroshilov wrote: > vf610_nfc_probe() misses error handling of mtd_device_register(). > > Found by Linux Driver Verification project (linuxtesting.org). > > Signed-off-by: Alexey Khoroshilov > --- > drivers/mtd/nand/vf610_nfc.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c > index 8037d4b48a05..a4c181af74b3 100644 > --- a/drivers/mtd/nand/vf610_nfc.c > +++ b/drivers/mtd/nand/vf610_nfc.c > @@ -782,7 +782,10 @@ static int vf610_nfc_probe(struct platform_device *pdev) > platform_set_drvdata(pdev, mtd); > > /* Register device in MTD */ > - return mtd_device_register(mtd, NULL, 0); > + err = mtd_device_register(mtd, NULL, 0); > + if (err) > + goto error; Nope, you're not entirely fixing the leak: nand_scan_tail() has to be undone with nand_cleanup(). > + return 0; > > error: > of_node_put(nand_get_flash_node(chip));