drm/bridge:Fix the panic problem caused by bridge->funcs->attach
Subsystems (3)
PATCH 1/1 drm/bridge:Fix the panic problem caused by bridge->funcs->attach
When the code is executed to bridge->funcs->attach,bridge->funcs is NULL. Although the function entry checks whether the bridge pointer is NULL,it does not detect whether the bridge->funcs is NULL, so a panic error occurs.
--- drivers/gpu/drm/drm_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_bridge.c +1 -1
@@ -302,7 +302,7 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, {int ret; -if (!encoder || !bridge) +if (!encoder || !bridge || !bridge->funcs)return -EINVAL ;if (previous && (!previous->dev || previous->encoder != encoder))
Signature · 1 line
2.17.1
Quoted 16 lines · logic.yu
When the code is executed to bridge->funcs->attach,bridge->funcs is NULL. Although the function entry checks whether the bridge pointer is NULL,it does not detect whether the
bridge->funcsis NULL, so a panic error occurs.Signed-off-by logic.yu <[email protected]>--- drivers/gpu/drm/drm_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_bridge.c +0
-0
drivers/gpu/drm/drm_bridge.c int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, · line 305
Quoted 5 lines
drivers/gpu/drm/drm_bridge.c +1
-1@@ -302,7 +302,7 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, {int ret; -if (!encoder || !bridge) +if (!encoder || !bridge || !bridge->funcs)
Would you please share the use case log where you found panic? I think checking bridge->funcs during funcs-> trigger later in this function would be a valid check (assume if an issue) as some drivers use the bridge to handle downstream bridge w/o using any bridge functions.
Jagan.
The log looks like this:
[ 31.723823] Internal error: Oops: 96000004 [#1] SMP\013 \010 [ 31.729030] Modules linked in:\013 \010 [ 31.733395] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.59+2.0.0 #250\013 \010 [ 31.745167] pstate: 60c00005 (nZCv daif +PAN +UAO -TCO BTYPE=--)\013 \010 [ 31.752785] pc : drm_bridge_attach+0xdc/0x1a4\013 \010 [ 31.757518] lr : drm_bridge_attach+0x40/0x1a4\013 \010 [ 31.762104] sp : ffff0000000678f0\013 \010 [ 31.765726] x29: ffff0000000678f0 x28: ffff00000031c880 \013 \010 [ 31.771599] x27: 0000000000000060 x26: ffff800010539e90 \013 \010 [ 31.777340] x25: ffff0000000a6000 x24: ffff000000129c10 \013 \010 [ 31.783060] x23: 0000000000000000 x22: ffff0000000131c0 \013 \010 [ 31.788770] x21: ffff80001052a5b8 x20: ffff0000003e2c80 \013 \010 [ 31.794506] x19: ffff000000017080 x18: 0000000000000010 \013 \010 [ 31.800210] x17: 000000005fcfcd6c x16: 00000000d27b105e \013 \010 [ 31.805907] x15: 00000000000000c7 x14: ffff0000000675d0 \013 \010 [ 31.811599] x13: 00000000ffffffea x12: ffff8000114158c0 \013 \010 [ 31.817282] x11: 0000000000000003 x10: ffff800011295880 \013 \010 [ 31.823000] x9 : ffff8000112958d8 x8 : 000000000017ffe8 \013 \010 [ 31.828731] x7 : c0000000fffeffff x6 : 0000000000000001 \013 \010 [ 31.834425] x5 : 000000000057ffa8 x4 : 0000000000000000 \013 \010 [ 31.840101] x3 : 0000000000000000 x2 : ffff000000013218 \013 \010 [ 31.845787] x1 : ffff0000003e2cf8 x0 : 0000000000000000 \013 \010 [ 31.851594] Call trace:\013 \010 [ 31.854603] drm_bridge_attach+0xdc/0x1a4\013 \010 [ 31.859079] dw_mipi_dsi_bridge_attach+0x98/0xa8\013 \010 [ 31.864035] drm_bridge_attach+0x104/0x1a4\013 \010 [ 31.869211] dw_mipi_dsi_bind+0x24/0x58\013 \010
drm_bridge_attach will call bridge->funcs in many cases, so I think it is necessary to check。
Quoted 31 lines · Jagan Teki <[email protected]> 于2023年4月18日周二 21:45写道:
drivers/gpu/drm/drm_bridge.c int drm_bridge_attach(struct drm_encoder *encoder,
Quoted 16 lines · logic.yu
When the code is executed to bridge->funcs->attach,bridge->funcs is NULL. Although the function entry checks whether the bridge pointer is NULL,it does not detect whether the
bridge->funcsis NULL, so a panic error occurs.Signed-off-by logic.yu <[email protected]>--- drivers/gpu/drm/drm_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_bridge.c +0
-0@@ -302,7 +302,7 @@ int drm_bridge_attach(struct drm_encoder *encoder,struct
drm_bridge*bridge,drivers/gpu/drm/drm_bridge.c int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, · line 305
Quoted 5 lines
drivers/gpu/drm/drm_bridge.c +1
-1{int ret; -if (!encoder || !bridge) +if (!encoder || !bridge || !bridge->funcs)Would you please share the use case log where you found panic? I think checking
bridge->funcsduring funcs-> trigger later in this function would be a valid check (assume if an issue) as some drivers use the bridge to handle downstream bridge w/o using any bridge functions.Jagan.
+ Bridge Maintainers
Quoted 30 lines · 余治国
The log looks like this:
[ 31.723823] Internal error: Oops: 96000004 [#1] SMP\013 \010 [ 31.729030] Modules linked in:\013 \010 [ 31.733395] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.59+2.0.0 #250\013 \010 [ 31.745167] pstate: 60c00005 (nZCv daif +PAN +UAO -TCO BTYPE=--)\013 \010 [ 31.752785] pc : drm_bridge_attach+0xdc/0x1a4\013 \010 [ 31.757518] lr : drm_bridge_attach+0x40/0x1a4\013 \010 [ 31.762104] sp : ffff0000000678f0\013 \010 [ 31.765726] x29: ffff0000000678f0 x28: ffff00000031c880 \013 \010 [ 31.771599] x27: 0000000000000060 x26: ffff800010539e90 \013 \010 [ 31.777340] x25: ffff0000000a6000 x24: ffff000000129c10 \013 \010 [ 31.783060] x23: 0000000000000000 x22: ffff0000000131c0 \013 \010 [ 31.788770] x21: ffff80001052a5b8 x20: ffff0000003e2c80 \013 \010 [ 31.794506] x19: ffff000000017080 x18: 0000000000000010 \013 \010 [ 31.800210] x17: 000000005fcfcd6c x16: 00000000d27b105e \013 \010 [ 31.805907] x15: 00000000000000c7 x14: ffff0000000675d0 \013 \010 [ 31.811599] x13: 00000000ffffffea x12: ffff8000114158c0 \013 \010 [ 31.817282] x11: 0000000000000003 x10: ffff800011295880 \013 \010 [ 31.823000] x9 : ffff8000112958d8 x8 : 000000000017ffe8 \013 \010 [ 31.828731] x7 : c0000000fffeffff x6 : 0000000000000001 \013 \010 [ 31.834425] x5 : 000000000057ffa8 x4 : 0000000000000000 \013 \010 [ 31.840101] x3 : 0000000000000000 x2 : ffff000000013218 \013 \010 [ 31.845787] x1 : ffff0000003e2cf8 x0 : 0000000000000000 \013 \010 [ 31.851594] Call trace:\013 \010 [ 31.854603] drm_bridge_attach+0xdc/0x1a4\013 \010 [ 31.859079] dw_mipi_dsi_bridge_attach+0x98/0xa8\013 \010 [ 31.864035] drm_bridge_attach+0x104/0x1a4\013 \010 [ 31.869211] dw_mipi_dsi_bind+0x24/0x58\013 \010
Quoted 1 line
drm_bridge_attachwill callbridge->funcsin many cases, so I think it is necessary to check。
I don't think the bridge pointer or bridge->funcs pointer is NULL here. It looks like the controlling is attaching the bridge prior to registering it. If I remember correctly, I got a similar issue with rockchip-drm pipeline. Would you please share your pipeline as well?
Thanks,
Jagan.
two separate pipeline:crtc->encoder->bridge->connector->panel
Quoted 46 lines · Jagan Teki <[email protected]> 于2023年4月23日周日 19:10写道:
+ Bridge Maintainers
Quoted 5 lines · 余治国
The log looks like this:
[ 31.723823] Internal error: Oops: 96000004 [#1] SMP\013 \010 [ 31.729030] Modules linked in:\013 \010 [ 31.733395] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.59+2.0.0#250\013
Quoted 2 lines
\010
[ 31.745167] pstate: 60c00005 (nZCv daif +PAN +UAO -TCO BTYPE=--)\013\010
Quoted 23 lines
[ 31.752785] pc : drm_bridge_attach+0xdc/0x1a4\013 \010 [ 31.757518] lr : drm_bridge_attach+0x40/0x1a4\013 \010 [ 31.762104] sp : ffff0000000678f0\013 \010 [ 31.765726] x29: ffff0000000678f0 x28: ffff00000031c880 \013 \010 [ 31.771599] x27: 0000000000000060 x26: ffff800010539e90 \013 \010 [ 31.777340] x25: ffff0000000a6000 x24: ffff000000129c10 \013 \010 [ 31.783060] x23: 0000000000000000 x22: ffff0000000131c0 \013 \010 [ 31.788770] x21: ffff80001052a5b8 x20: ffff0000003e2c80 \013 \010 [ 31.794506] x19: ffff000000017080 x18: 0000000000000010 \013 \010 [ 31.800210] x17: 000000005fcfcd6c x16: 00000000d27b105e \013 \010 [ 31.805907] x15: 00000000000000c7 x14: ffff0000000675d0 \013 \010 [ 31.811599] x13: 00000000ffffffea x12: ffff8000114158c0 \013 \010 [ 31.817282] x11: 0000000000000003 x10: ffff800011295880 \013 \010 [ 31.823000] x9 : ffff8000112958d8 x8 : 000000000017ffe8 \013 \010 [ 31.828731] x7 : c0000000fffeffff x6 : 0000000000000001 \013 \010 [ 31.834425] x5 : 000000000057ffa8 x4 : 0000000000000000 \013 \010 [ 31.840101] x3 : 0000000000000000 x2 : ffff000000013218 \013 \010 [ 31.845787] x1 : ffff0000003e2cf8 x0 : 0000000000000000 \013 \010 [ 31.851594] Call trace:\013 \010 [ 31.854603] drm_bridge_attach+0xdc/0x1a4\013 \010 [ 31.859079] dw_mipi_dsi_bridge_attach+0x98/0xa8\013 \010 [ 31.864035] drm_bridge_attach+0x104/0x1a4\013 \010 [ 31.869211] dw_mipi_dsi_bind+0x24/0x58\013 \010Quoted 1 line
drm_bridge_attachwill callbridge->funcsin many cases, so I think itis necessary to check。
I don't think the bridge pointer or
bridge->funcspointer is NULL here. It looks like the controlling is attaching the bridge prior to registering it. If I remember correctly, I got a similar issue with rockchip-drm pipeline. Would you please share your pipeline as well?Thanks,
Jagan.