Skip to content

Commit 81adbd3

Browse files
bijudaslumag
authored andcommitted
drm: adv7511: Fix use-after-free in adv7533_attach_dsi()
The host_node pointer was assigned and freed in adv7533_parse_dt(), and later, adv7533_attach_dsi() uses the same. Fix this use-after-free issue by dropping of_node_put() in adv7533_parse_dt() and calling of_node_put() in error path of probe() and also in the remove(). Fixes: 1e4d58c ("drm/bridge: adv7533: Create a MIPI DSI device") Cc: [email protected] Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Biju Das <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 902806b commit 81adbd3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,8 +1241,10 @@ static int adv7511_probe(struct i2c_client *i2c)
12411241
return ret;
12421242

12431243
ret = adv7511_init_regulators(adv7511);
1244-
if (ret)
1245-
return dev_err_probe(dev, ret, "failed to init regulators\n");
1244+
if (ret) {
1245+
dev_err_probe(dev, ret, "failed to init regulators\n");
1246+
goto err_of_node_put;
1247+
}
12461248

12471249
/*
12481250
* The power down GPIO is optional. If present, toggle it from active to
@@ -1363,6 +1365,8 @@ static int adv7511_probe(struct i2c_client *i2c)
13631365
i2c_unregister_device(adv7511->i2c_edid);
13641366
uninit_regulators:
13651367
adv7511_uninit_regulators(adv7511);
1368+
err_of_node_put:
1369+
of_node_put(adv7511->host_node);
13661370

13671371
return ret;
13681372
}
@@ -1371,6 +1375,8 @@ static void adv7511_remove(struct i2c_client *i2c)
13711375
{
13721376
struct adv7511 *adv7511 = i2c_get_clientdata(i2c);
13731377

1378+
of_node_put(adv7511->host_node);
1379+
13741380
adv7511_uninit_regulators(adv7511);
13751381

13761382
drm_bridge_remove(&adv7511->bridge);

drivers/gpu/drm/bridge/adv7511/adv7533.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@ int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv)
181181
if (!adv->host_node)
182182
return -ENODEV;
183183

184-
of_node_put(adv->host_node);
185-
186184
adv->use_timing_gen = !of_property_read_bool(np,
187185
"adi,disable-timing-generator");
188186

0 commit comments

Comments
 (0)