drm: bridge: it66121: fix an error code in it66121_probe()
Subsystems (5)
PATCH 1/2 drm: bridge: it66121: fix an error code in it66121_probe()
This code is passing the wrong variable to PTR_ERR() so it doesn't return the correct error code.
--- drivers/gpu/drm/bridge/ite-it66121.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it66121.c +1 -1
@@ -943,7 +943,7 @@ static int it66121_probe(struct i2c_client *client, ctx->regmap =devm_regmap_init_i2c (client, &it66121_regmap_config);if (IS_ERR (ctx->regmap)) {ite66121_power_off (ctx); -return PTR_ERR (ctx); +return PTR_ERR (ctx->regmap); }regmap_read (ctx->regmap,IT66121_VENDOR_ID0_REG , &vendor_ids[0 ]);
Signature · 1 line
2.30.2
PATCH 2/2 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().
--- drivers/gpu/drm/bridge/ite-it66121.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/ite-it66121.c +4 -4
@@ -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;
Signature · 1 line
2.30.2
Re: [PATCH 2/2] drm: bridge: it66121: fix a resource leak in probe
Quoted 25 lines · Dan Carpenter
In the original code if the "ctx =
devm_kzalloc()" allocation failed then we should have calledof_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 988156dc2fc9 ("drm: bridge: add it66121 driver")Signed-off-by Dan Carpenter <[email protected]>--- drivers/gpu/drm/bridge/ite-it66121.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/bridge/ite-it66121.c +0
-4@@ -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 );
drivers/gpu/drm/bridge/ite-it66121.c static int it66121_probe(struct i2c_client *client, · line 911
Quoted 10 lines
drivers/gpu/drm/bridge/ite-it66121.c +4
-0if (!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;
Thanks !
Applying to drm-misc-fixes
Quoted 15 lines · Dan Carpenter
This code is passing the wrong variable to
PTR_ERR()so it doesn't return the correct error code.Fixes 988156dc2fc9 ("drm: bridge: add it66121 driver")Signed-off-by Dan Carpenter <[email protected]>--- drivers/gpu/drm/bridge/ite-it66121.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/bridge/ite-it66121.c +0
-0
drivers/gpu/drm/bridge/ite-it66121.c static int it66121_probe(struct i2c_client *client, · line 949
Quoted 8 lines
drivers/gpu/drm/bridge/ite-it66121.c +1
-1@@ -943,7 +943,7 @@ static int it66121_probe(struct i2c_client *client, ctx->regmap =devm_regmap_init_i2c (client, &it66121_regmap_config);if (IS_ERR (ctx->regmap)) {ite66121_power_off (ctx); -return PTR_ERR (ctx); +return PTR_ERR (ctx->regmap); }regmap_read (ctx->regmap,IT66121_VENDOR_ID0_REG , &vendor_ids[0 ]);
Thanks !
Applying to drm-misc-fixes