Skip to content

Commit d208571

Browse files
bijudasgregkh
authored andcommitted
drm: adv7511: Fix use-after-free in adv7533_attach_dsi()
[ Upstream commit 81adbd3ff21c1182e06aa02c6be0bfd9ea02d8e8 ] 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: Sasha Levin <[email protected]>
1 parent 90d4d27 commit d208571

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
@@ -1224,8 +1224,10 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
12241224
return ret;
12251225

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

12301232
/*
12311233
* The power down GPIO is optional. If present, toggle it from active to
@@ -1345,6 +1347,8 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
13451347
i2c_unregister_device(adv7511->i2c_edid);
13461348
uninit_regulators:
13471349
adv7511_uninit_regulators(adv7511);
1350+
err_of_node_put:
1351+
of_node_put(adv7511->host_node);
13481352

13491353
return ret;
13501354
}
@@ -1353,6 +1357,8 @@ static void adv7511_remove(struct i2c_client *i2c)
13531357
{
13541358
struct adv7511 *adv7511 = i2c_get_clientdata(i2c);
13551359

1360+
of_node_put(adv7511->host_node);
1361+
13561362
adv7511_uninit_regulators(adv7511);
13571363

13581364
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)