Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: phram: only call platform_driver_unregister if phram_setup fails

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>

authored by

Colin Ian King and committed by
Miquel Raynal
78a56df6 40384c84

+4 -4
+4 -4
drivers/mtd/devices/phram.c
··· 415 415 return ret; 416 416 417 417 #ifndef MODULE 418 - if (phram_paramline[0]) 418 + if (phram_paramline[0]) { 419 419 ret = phram_setup(phram_paramline); 420 + if (ret) 421 + platform_driver_unregister(&phram_driver); 422 + } 420 423 phram_init_called = 1; 421 424 #endif 422 - 423 - if (ret) 424 - platform_driver_unregister(&phram_driver); 425 425 426 426 return ret; 427 427 }