mtd: nand: gpmi: Fix gpmi_nand_init() error path
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Mon, 10 Apr 2017 08:35:17 +0000 (10:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Apr 2018 17:48:15 +0000 (19:48 +0200)
commit8bf4782062a0a0f6b9ca68f3f6625e1a5fe455fc
treebcafbeffd099d11113e230d33a4510a23f9a3816
parented82ab87e13899458dda17d52a11e5b63fc15582
mtd: nand: gpmi: Fix gpmi_nand_init() error path

[ Upstream commit 4d02423e9afe6c46142ce98bbcaf5167316dbfbf ]

The GPMI driver is wrongly assuming that nand_release() can safely be
called on an uninitialized/unregistered NAND device.

Add a new err_nand_cleanup label in the error path and only execute if
nand_scan_tail() succeeded.

Note that we now call nand_cleanup() instead of nand_release()
(nand_release() is actually grouping the mtd_device_unregister() and
nand_cleanup() in one call) because there's no point in trying to
unregister a device that has never been registered.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Acked-by: Han Xu <han.xu@nxp.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/nand/gpmi-nand/gpmi-nand.c