]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mtd: phram: only call platform_driver_unregister if phram_setup fails
authorColin Ian King <colin.i.king@gmail.com>
Wed, 30 Oct 2024 17:21:49 +0000 (17:21 +0000)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 5 Dec 2024 10:09:53 +0000 (11:09 +0100)
The check on ret and call to platform_driver_unregister is only required
in the code path where MODULE is not defined. Fix this by moving this
code into the relevant place after the call to phram_setup.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/devices/phram.c

index f756c60a4931d5d62eb1aafb719621011cb9c09a..b8bbc7ecbe953835e2bef3540f90656a55a0ceff 100644 (file)
@@ -415,14 +415,14 @@ static int __init init_phram(void)
                return ret;
 
 #ifndef MODULE
-       if (phram_paramline[0])
+       if (phram_paramline[0]) {
                ret = phram_setup(phram_paramline);
+               if (ret)
+                       platform_driver_unregister(&phram_driver);
+       }
        phram_init_called = 1;
 #endif
 
-       if (ret)
-               platform_driver_unregister(&phram_driver);
-
        return ret;
 }