Skip to content

Commit

Permalink
drm/imx: parallel-display: fix edid memory leak
Browse files Browse the repository at this point in the history
The edid memory is only freed if the component.unbind() is called. This
is okay if the parallel-display was bound but if the bind() fails we
leak the memory.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
[p.zabel@pengutronix.de: rebased, dropped now empty unbind()]
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
  • Loading branch information
Marco Felsch authored and Philipp Zabel committed Oct 27, 2020
1 parent 754e0b5 commit 5f2ca76
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions drivers/gpu/drm/imx/parallel-display.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)

edidp = of_get_property(np, "edid", &imxpd->edid_len);
if (edidp)
imxpd->edid = kmemdup(edidp, imxpd->edid_len, GFP_KERNEL);
imxpd->edid = devm_kmemdup(dev, edidp, imxpd->edid_len,
GFP_KERNEL);

ret = of_property_read_string(np, "interface-pix-fmt", &fmt);
if (!ret) {
Expand All @@ -349,17 +350,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
return 0;
}

static void imx_pd_unbind(struct device *dev, struct device *master,
void *data)
{
struct imx_parallel_display *imxpd = dev_get_drvdata(dev);

kfree(imxpd->edid);
}

static const struct component_ops imx_pd_ops = {
.bind = imx_pd_bind,
.unbind = imx_pd_unbind,
};

static int imx_pd_probe(struct platform_device *pdev)
Expand Down

0 comments on commit 5f2ca76

Please sign in to comment.