]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: wfx: Fix error handling in wfx_core_init()
authorYuan Can <yuancan@huawei.com>
Tue, 22 Oct 2024 09:04:53 +0000 (17:04 +0800)
committerKalle Valo <kvalo@kernel.org>
Thu, 31 Oct 2024 14:18:42 +0000 (16:18 +0200)
The wfx_core_init() returns without checking the retval from
sdio_register_driver().
If the sdio_register_driver() failed, the module failed to install,
leaving the wfx_spi_driver not unregistered.

Fixes: a7a91ca5a23d ("staging: wfx: add infrastructure for new driver")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Reviewed-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://patch.msgid.link/20241022090453.84679-1-yuancan@huawei.com
drivers/net/wireless/silabs/wfx/main.c

index e7198520bdffc7f9754566079cb1a5965c7825de..64441c8bc4606cd4e6c4f245190f4864cf500a41 100644 (file)
@@ -480,10 +480,23 @@ static int __init wfx_core_init(void)
 {
        int ret = 0;
 
-       if (IS_ENABLED(CONFIG_SPI))
+       if (IS_ENABLED(CONFIG_SPI)) {
                ret = spi_register_driver(&wfx_spi_driver);
-       if (IS_ENABLED(CONFIG_MMC) && !ret)
+               if (ret)
+                       goto out;
+       }
+       if (IS_ENABLED(CONFIG_MMC)) {
                ret = sdio_register_driver(&wfx_sdio_driver);
+               if (ret)
+                       goto unregister_spi;
+       }
+
+       return 0;
+
+unregister_spi:
+       if (IS_ENABLED(CONFIG_SPI))
+               spi_unregister_driver(&wfx_spi_driver);
+out:
        return ret;
 }
 module_init(wfx_core_init);