drm: bridge: it66121: fix a resource leak in probe

In the original code if the "ctx = devm_kzalloc()" allocation failed
then we should have called of_node_put(ep); before returning.  It's
actually a bit easier to do the allocation first before assigning
ep = of_graph_get_endpoint_by_regs().

Fixes: 988156dc2f ("drm: bridge: add it66121 driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/YJ+ZgXTFa6voZuJG@mwanda
This commit is contained in:
Dan Carpenter 2021-05-15 12:50:57 +03:00 committed by Neil Armstrong
parent 69fbffcc30
commit 337ed732b3
1 changed files with 4 additions and 4 deletions

View File

@ -898,14 +898,14 @@ static int it66121_probe(struct i2c_client *client,
return -ENXIO;
}
ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0);
if (!ep)
return -EINVAL;
ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0);
if (!ep)
return -EINVAL;
ctx->dev = dev;
ctx->client = client;