Skip to content

Commit 1f49aaf

Browse files
bijudasgregkh
authored andcommitted
drm: adv7511: Fix use-after-free in adv7533_attach_dsi()
commit 81adbd3 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 79fcfc9 commit 1f49aaf

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
@@ -1225,8 +1225,10 @@ static int adv7511_probe(struct i2c_client *i2c)
12251225
return ret;
12261226

12271227
ret = adv7511_init_regulators(adv7511);
1228-
if (ret)
1229-
return dev_err_probe(dev, ret, "failed to init regulators\n");
1228+
if (ret) {
1229+
dev_err_probe(dev, ret, "failed to init regulators\n");
1230+
goto err_of_node_put;
1231+
}
12301232

12311233
/*
12321234
* The power down GPIO is optional. If present, toggle it from active to
@@ -1346,6 +1348,8 @@ static int adv7511_probe(struct i2c_client *i2c)
13461348
i2c_unregister_device(adv7511->i2c_edid);
13471349
uninit_regulators:
13481350
adv7511_uninit_regulators(adv7511);
1351+
err_of_node_put:
1352+
of_node_put(adv7511->host_node);
13491353

13501354
return ret;
13511355
}
@@ -1354,6 +1358,8 @@ static void adv7511_remove(struct i2c_client *i2c)
13541358
{
13551359
struct adv7511 *adv7511 = i2c_get_clientdata(i2c);
13561360

1361+
of_node_put(adv7511->host_node);
1362+
13571363
adv7511_uninit_regulators(adv7511);
13581364

13591365
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
@@ -184,8 +184,6 @@ int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv)
184184
if (!adv->host_node)
185185
return -ENODEV;
186186

187-
of_node_put(adv->host_node);
188-
189187
adv->use_timing_gen = !of_property_read_bool(np,
190188
"adi,disable-timing-generator");
191189

0 commit comments

Comments
 (0)