Skip to contentSkip to conversation

drm/bridge: chipone-icn6211: use devm_drm_bridge_add in dsi probe

PATCH Superseded Osama Abdelkader 2 participants 4 messages Apr 23 – Apr 30

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 2/2 drm/bridge: chipone-icn6211: use devm_drm_bridge_add in dsi probe

Use devm_drm_bridge_add() so the bridge is released if probe fails after registration, and drop drm_bridge_remove() in chipone_dsi_probe.

---
v3: split the patch into two, one for i2c probe (bugfix) and one for dsi probe
v2: devm_drm_bridge_add instead of drm_bridge_add

---
 drivers/gpu/drm/bridge/chipone-icn6211.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/chipone-icn6211.c +3 -5
index 4d76e1bd5e78..f53e64129ebe 100644
@@ -730,13 +730,11 @@ static int chipone_dsi_probe(struct mipi_dsi_device *dsi)
 
 	mipi_dsi_set_drvdata(dsi, icn);
 
-	drm_bridge_add(&icn->bridge);
-
-	ret = chipone_dsi_attach(icn);
+	ret = devm_drm_bridge_add(dev, &icn->bridge);
 	if (ret)
-		drm_bridge_remove(&icn->bridge);
+		return ret;
 
-	return ret;
+	return chipone_dsi_attach(icn);
 }
 
 static int chipone_i2c_probe(struct i2c_client *client)
Signature · 1 line
2.43.0
reviewer Reviewed-by on v3 2/2
#1 lore raw
Quoted 7 lines · Osama Abdelkader

Use devm_drm_bridge_add() so the bridge is released if probe fails after registration, and drop drm_bridge_remove() in chipone_dsi_probe.

---
v3: split the patch into two, one for i2c probe (bugfix) and one for dsi probe
v2: devm_drm_bridge_add instead of drm_bridge_add

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

reviewer
#2 lore raw
In reply to Osama Abdelkader

Hello Osama,

Quoted 2 lines · Osama Abdelkader

Use devm_drm_bridge_add() so the bridge is released if probe fails after registration, and drop drm_bridge_remove() in chipone_dsi_probe.

Wait, this patch must drop drm_bridge_remove() in chipone_dsi_remove() too! Otherwise it'd be introducing an excess put, and consequent use-after-free.

I have to withdraw my R-by.

You can amend in v4.

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

#3 lore raw

Hello Luca,

Quoted 6 lines · Luca Ceresoli

Hello Osama,

Quoted 2 lines · Osama Abdelkader

Use devm_drm_bridge_add() so the bridge is released if probe fails after registration, and drop drm_bridge_remove() in chipone_dsi_probe.

Quoted 7 lines

Wait, this patch must drop drm_bridge_remove() in chipone_dsi_remove() too! Otherwise it'd be introducing an excess put, and consequent use-after-free.

I have to withdraw my R-by.

You can amend in v4.

Good catch, added now in v4.

Thanks,
Osama

Quoted 6 lines

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com