fbdev: via: Fix error in via_core_init()
authorShang XiaoJing <shangxiaojing@huawei.com>
Mon, 14 Nov 2022 01:08:52 +0000 (09:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:43 +0000 (13:32 +0100)
[ Upstream commit 5886b130de953cfb8826f7771ec8640a79934a7f ]

via_core_init() won't exit the driver when pci_register_driver() failed.
Exit the viafb-i2c and the viafb-gpio in failed path to prevent error.

VIA Graphics Integration Chipset framebuffer 2.4 initializing
Error: Driver 'viafb-i2c' is already registered, aborting...
Error: Driver 'viafb-gpio' is already registered, aborting...

Fixes: 7582eb9be85f ("viafb: Turn GPIO and i2c into proper platform devices")
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/video/fbdev/via/via-core.c

index 2ee8fcae08dfbbf3fe1dac69643ed0dc1ee88940..b8cd04defc5e283af40bb6690dda7f1d7edcc1ba 100644 (file)
@@ -730,7 +730,14 @@ static int __init via_core_init(void)
                return ret;
        viafb_i2c_init();
        viafb_gpio_init();
-       return pci_register_driver(&via_driver);
+       ret = pci_register_driver(&via_driver);
+       if (ret) {
+               viafb_gpio_exit();
+               viafb_i2c_exit();
+               return ret;
+       }
+
+       return 0;
 }
 
 static void __exit via_core_exit(void)