drm/bridge: synopsys: dw-hdmi: Delete i2c adapter when hdmi bind failed

If hdmi i2c adapter is not deleted when hdmi bind failed, there
may be a crash when other device added. Because hdmi i2c memory
was freed but hdmi i2c still in the kobj list, its address may
be accessed when other device was added to the kobj list.

BUG: KASAN: use-after-free in __list_add_valid+0x3c/0xc8
Read of size 8 at addr ffffff80065930f8 by task swapper/0/1

CPU: 4 PID: 1 Comm: swapper/0 Not tainted 5.10.43 #294
Hardware name: Rockchip RK3399 EVB IND LPDDR4 Board edp (Android) (DT)
Call trace:
 dump_backtrace+0x0/0x2d0
 show_stack+0x18/0x28
 dump_stack_lvl+0xfc/0x138
 print_address_description.constprop.13+0x7c/0x31c
 kasan_report+0x1e8/0x250
 __asan_load8+0x9c/0xd8
 __list_add_valid+0x3c/0xc8
 kobject_add_internal+0xbc/0x400
 kobject_add+0x108/0x1a8
 device_add+0x1b8/0xc10
 device_link_add+0x63c/0x8c8
 _regulator_get+0x148/0x3a8
 _devm_regulator_get+0x50/0xc8
 devm_regulator_get+0x14/0x20
 panel_simple_probe+0x120/0x538
 panel_simple_platform_probe+0x60/0xf8
 platform_drv_probe+0x70/0xd0
 really_probe+0x148/0x558
 driver_probe_device+0x78/0xe8
 device_driver_attach+0x9c/0xa8
 __driver_attach+0x74/0x118
 bus_for_each_dev+0xec/0x160
 driver_attach+0x34/0x48
 bus_add_driver+0x244/0x2a0
 driver_register+0xc0/0x1e0
 __platform_driver_register+0x80/0x90
 panel_simple_init+0x24/0x4c
 do_one_initcall+0xa0/0x420
 kernel_init_freeable+0x2f0/0x374
 kernel_init+0x14/0x120

Signed-off-by: Algea Cao <algea.cao@rock-chips.com>
Change-Id: Ifc38263ce52f951f6dd0fb83ac1a76facd98445e
This commit is contained in:
Algea Cao
2021-10-21 18:59:53 +08:00
committed by Tao Huang
parent 7b772c40d3
commit fddab04238

View File

@@ -4712,7 +4712,10 @@ err_iahb:
err_isfr:
clk_disable_unprepare(hdmi->isfr_clk);
err_res:
i2c_put_adapter(hdmi->ddc);
if (hdmi->i2c)
i2c_del_adapter(&hdmi->i2c->adap);
else
i2c_put_adapter(hdmi->ddc);
return ERR_PTR(ret);
}