Skip to content

Commit 08ac6f1

Browse files
tombasuperna9999
authored andcommitted
drm/bridge: sii902x: Fix probing race issue
A null pointer dereference crash has been observed rarely on TI platforms using sii9022 bridge: [ 53.271356] sii902x_get_edid+0x34/0x70 [sii902x] [ 53.276066] sii902x_bridge_get_edid+0x14/0x20 [sii902x] [ 53.281381] drm_bridge_get_edid+0x20/0x34 [drm] [ 53.286305] drm_bridge_connector_get_modes+0x8c/0xcc [drm_kms_helper] [ 53.292955] drm_helper_probe_single_connector_modes+0x190/0x538 [drm_kms_helper] [ 53.300510] drm_client_modeset_probe+0x1f0/0xbd4 [drm] [ 53.305958] __drm_fb_helper_initial_config_and_unlock+0x50/0x510 [drm_kms_helper] [ 53.313611] drm_fb_helper_initial_config+0x48/0x58 [drm_kms_helper] [ 53.320039] drm_fbdev_dma_client_hotplug+0x84/0xd4 [drm_dma_helper] [ 53.326401] drm_client_register+0x5c/0xa0 [drm] [ 53.331216] drm_fbdev_dma_setup+0xc8/0x13c [drm_dma_helper] [ 53.336881] tidss_probe+0x128/0x264 [tidss] [ 53.341174] platform_probe+0x68/0xc4 [ 53.344841] really_probe+0x188/0x3c4 [ 53.348501] __driver_probe_device+0x7c/0x16c [ 53.352854] driver_probe_device+0x3c/0x10c [ 53.357033] __device_attach_driver+0xbc/0x158 [ 53.361472] bus_for_each_drv+0x88/0xe8 [ 53.365303] __device_attach+0xa0/0x1b4 [ 53.369135] device_initial_probe+0x14/0x20 [ 53.373314] bus_probe_device+0xb0/0xb4 [ 53.377145] deferred_probe_work_func+0xcc/0x124 [ 53.381757] process_one_work+0x1f0/0x518 [ 53.385770] worker_thread+0x1e8/0x3dc [ 53.389519] kthread+0x11c/0x120 [ 53.392750] ret_from_fork+0x10/0x20 The issue here is as follows: - tidss probes, but is deferred as sii902x is still missing. - sii902x starts probing and enters sii902x_init(). - sii902x calls drm_bridge_add(). Now the sii902x bridge is ready from DRM's perspective. - sii902x calls sii902x_audio_codec_init() and platform_device_register_data() - The registration of the audio platform device causes probing of the deferred devices. - tidss probes, which eventually causes sii902x_bridge_get_edid() to be called. - sii902x_bridge_get_edid() tries to use the i2c to read the edid. However, the sii902x driver has not set up the i2c part yet, leading to the crash. Fix this by moving the drm_bridge_add() to the end of the sii902x_init(), which is also at the very end of sii902x_probe(). Signed-off-by: Tomi Valkeinen <[email protected]> Fixes: 21d8084 ("drm/bridge/sii902x: Fix EDID readback") Acked-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Neil Armstrong <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 589830b commit 08ac6f1

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

drivers/gpu/drm/bridge/sii902x.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,16 +1080,6 @@ static int sii902x_init(struct sii902x *sii902x)
10801080
return ret;
10811081
}
10821082

1083-
sii902x->bridge.funcs = &sii902x_bridge_funcs;
1084-
sii902x->bridge.of_node = dev->of_node;
1085-
sii902x->bridge.timings = &default_sii902x_timings;
1086-
sii902x->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID;
1087-
1088-
if (sii902x->i2c->irq > 0)
1089-
sii902x->bridge.ops |= DRM_BRIDGE_OP_HPD;
1090-
1091-
drm_bridge_add(&sii902x->bridge);
1092-
10931083
sii902x_audio_codec_init(sii902x, dev);
10941084

10951085
i2c_set_clientdata(sii902x->i2c, sii902x);
@@ -1102,7 +1092,21 @@ static int sii902x_init(struct sii902x *sii902x)
11021092
return -ENOMEM;
11031093

11041094
sii902x->i2cmux->priv = sii902x;
1105-
return i2c_mux_add_adapter(sii902x->i2cmux, 0, 0, 0);
1095+
ret = i2c_mux_add_adapter(sii902x->i2cmux, 0, 0, 0);
1096+
if (ret)
1097+
return ret;
1098+
1099+
sii902x->bridge.funcs = &sii902x_bridge_funcs;
1100+
sii902x->bridge.of_node = dev->of_node;
1101+
sii902x->bridge.timings = &default_sii902x_timings;
1102+
sii902x->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID;
1103+
1104+
if (sii902x->i2c->irq > 0)
1105+
sii902x->bridge.ops |= DRM_BRIDGE_OP_HPD;
1106+
1107+
drm_bridge_add(&sii902x->bridge);
1108+
1109+
return 0;
11061110
}
11071111

11081112
static int sii902x_probe(struct i2c_client *client)
@@ -1170,12 +1174,11 @@ static int sii902x_probe(struct i2c_client *client)
11701174
}
11711175

11721176
static void sii902x_remove(struct i2c_client *client)
1173-
11741177
{
11751178
struct sii902x *sii902x = i2c_get_clientdata(client);
11761179

1177-
i2c_mux_del_adapters(sii902x->i2cmux);
11781180
drm_bridge_remove(&sii902x->bridge);
1181+
i2c_mux_del_adapters(sii902x->i2cmux);
11791182
}
11801183

11811184
static const struct of_device_id sii902x_dt_ids[] = {

0 commit comments

Comments
 (0)