drm/bridge: megachips: remove bridge when irq request fails
Subsystems (5)
PATCH v4 3/3 drm/bridge: megachips: remove bridge when irq request fails
If devm_request_threaded_irq() fails after drm_bridge_add(), remove the bridge before returning.
Keep drm_bridge_add() rather than devm_drm_bridge_add(): registration is tied to the STDP4028 device while ge_b850v3_register() may complete from either I2C probe; devm would not unwind the bridge if the other client's probe fails.
---
v4: update Fixes tag
v3: add Fixes and Cc tags
v2: IRQ failure path only (explicit drm_bridge_remove)
--- .../drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +10 -6
@@ -251,7 +251,6 @@ static void ge_b850v3_lvds_remove(void) goto out;drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge); - ge_b850v3_lvds_ptr =NULL ; out:mutex_unlock (&ge_b850v3_lvds_dev_mutex);
@@ -261,6 +260,7 @@ static int ge_b850v3_register(void) {struct i2c_client *stdp4028_i2c = ge_b850v3_lvds_ptr->stdp4028_i2c;struct device *dev = &stdp4028_i2c->dev; +int ret;/* drm bridge initialization */ ge_b850v3_lvds_ptr->bridge.ops = DRM_BRIDGE_OP_DETECT |
@@ -277,11 +277,15 @@ static int ge_b850v3_register(void)if (!stdp4028_i2c->irq)return 0 ; -return devm_request_threaded_irq (&stdp4028_i2c->dev, - stdp4028_i2c->irq,NULL , - ge_b850v3_lvds_irq_handler, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , -"ge-b850v3-lvds-dp" , ge_b850v3_lvds_ptr); + ret =devm_request_threaded_irq (&stdp4028_i2c->dev, + stdp4028_i2c->irq,NULL , + ge_b850v3_lvds_irq_handler, +IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +"ge-b850v3-lvds-dp" , ge_b850v3_lvds_ptr); +if (ret) +drm_bridge_remove (&ge_b850v3_lvds_ptr->bridge); + +return ret; }static int stdp4028_ge_b850v3_fw_probe (struct i2c_client *stdp4028_i2c)
Signature · 1 line
2.43.0
Quoted 7 lines · Osama Abdelkader
If
devm_request_threaded_irq()fails afterdrm_bridge_add(), remove the bridge before returning.Keep
drm_bridge_add()rather thandevm_drm_bridge_add(): registration is tied to the STDP4028 device whilege_b850v3_register()may complete from either I2C probe; devm would not unwind the bridge if the other client's probe fails.
I had a hard time in getting what you mean, until I noticed the global (ugh) ge_b850v3_lvds_ptr and the two "Only register after both bridges are probed" checks. Pretty hacky, but definitely for the sake of the fix you're introducing your patch will be OK.
Quoted 3 lines
Signed-off-by Osama Abdelkader <[email protected]>Fixes fcfa0ddc18ed ("drm/bridge: Drivers for megachips-stdpxxxx-ge-b850v3-fw (LVDS-DP++)")
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Quoted 14 lines · Luca Ceresoli
Quoted 7 lines · Osama Abdelkader
If
devm_request_threaded_irq()fails afterdrm_bridge_add(), remove the bridge before returning.Keep
drm_bridge_add()rather thandevm_drm_bridge_add(): registration is tied to the STDP4028 device whilege_b850v3_register()may complete from either I2C probe; devm would not unwind the bridge if the other client's probe fails.I had a hard time in getting what you mean, until I noticed the global (ugh)
ge_b850v3_lvds_ptrand the two "Only register after both bridges are probed" checks. Pretty hacky, but definitely for the sake of the fix you're introducing your patch will be OK.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Osama Abdelkader <[email protected]>Fixes fcfa0ddc18ed ("drm/bridge: Drivers for megachips-stdpxxxx-ge-b850v3-fw (LVDS-DP++)")Reviewed-by Luca Ceresoli <[email protected]>
Tested boot and hot-plug, no regressions found. Side-note: an update to MAINTAINERS has also been accepted [1].
[1] https://lore.kernel.org/all/[email protected]/
Quoted 5 lines
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Quoted 9 lines · Osama Abdelkader
If
devm_request_threaded_irq()fails afterdrm_bridge_add(), remove the bridge before returning.Keep
drm_bridge_add()rather thandevm_drm_bridge_add(): registration is tied to the STDP4028 device whilege_b850v3_register()may complete from either I2C probe; devm would not unwind the bridge if the other client's probe fails.[...]
Applied, thanks!
[3/3] drm/bridge: megachips: remove bridge when irq request fails
commit: d45d5c819f2cd0b6b5d76a194a537a5f4aeefecb
Best regards,
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com