mirror of
https://github.com/torvalds/linux.git
synced 2024-12-02 09:01:34 +00:00
drm/bridge: megachips: Fix error handling in i2c_register_driver()
A problem about insmod megachips-stdpxxxx-ge-b850v3-fw.ko failed is
triggered with the following log given:
[ 4497.981497] Error: Driver 'stdp4028-ge-b850v3-fw' is already registered, aborting...
insmod: ERROR: could not insert module megachips-stdpxxxx-ge-b850v3-fw.ko: Device or resource busy
The reason is that stdpxxxx_ge_b850v3_init() returns i2c_add_driver()
directly without checking its return value, if i2c_add_driver() failed,
it returns without calling i2c_del_driver() on the previous i2c driver,
resulting the megachips-stdpxxxx-ge-b850v3-fw can never be installed
later.
A simple call graph is shown as below:
stdpxxxx_ge_b850v3_init()
i2c_add_driver(&stdp4028_ge_b850v3_fw_driver)
i2c_add_driver(&stdp2690_ge_b850v3_fw_driver)
i2c_register_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without delete stdp4028_ge_b850v3_fw_driver
Fix by calling i2c_del_driver() on stdp4028_ge_b850v3_fw_driver when
i2c_add_driver() returns error.
Fixes: fcfa0ddc18
("drm/bridge: Drivers for megachips-stdpxxxx-ge-b850v3-fw (LVDS-DP++)")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Tested-by: Ian Ray <ian.ray@ge.com>
Signed-off-by: Robert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20221108091226.114524-1-yuancan@huawei.com
This commit is contained in:
parent
11ffff9284
commit
4ecff954c3
@ -440,7 +440,11 @@ static int __init stdpxxxx_ge_b850v3_init(void)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return i2c_add_driver(&stdp2690_ge_b850v3_fw_driver);
|
||||
ret = i2c_add_driver(&stdp2690_ge_b850v3_fw_driver);
|
||||
if (ret)
|
||||
i2c_del_driver(&stdp4028_ge_b850v3_fw_driver);
|
||||
|
||||
return ret;
|
||||
}
|
||||
module_init(stdpxxxx_ge_b850v3_init);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user