From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1eyWRv-0003TK-5R for linux-mtd@lists.infradead.org; Wed, 21 Mar 2018 05:38:13 +0000 Received: by mail-pl0-x244.google.com with SMTP id f23-v6so2521615plr.10 for ; Tue, 20 Mar 2018 22:38:00 -0700 (PDT) Date: Wed, 21 Mar 2018 11:07:09 +0530 From: Arushi Singhal To: dwmw2@infradead.org Cc: Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , Cyrille Pitchen , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] mtd: devices: check mtd_device_register() return code Message-ID: <20180321053709.GA5611@seema-Inspiron-15-3567> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , stfsm_probe() misses error handling of mtd_device_register(). Signed-off-by: Arushi Singhal --- drivers/mtd/devices/st_spi_fsm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 7bc29d7..e1aa4f8 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -2125,7 +2125,13 @@ static int stfsm_probe(struct platform_device *pdev) (long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20), fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10)); - return mtd_device_register(&fsm->mtd, NULL, 0); + ret = mtd_device_register(&fsm->mtd, NULL, 0); + if (ret) { + pr_err("Failed to register device\n"); + return ret; + } + + return 0; err_clk_unprepare: clk_disable_unprepare(fsm->clk); -- 2.7.4