Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] drm/imx: fix memory leak in imx_pd_bind
@ 2019-10-04 19:09 Navid Emamdoost
  2019-10-05 15:02 ` Markus Elfring
  2019-10-06  9:33 ` drm/imx: Checking a kmemdup() call in imx_pd_bind() Markus Elfring
  0 siblings, 2 replies; 12+ messages in thread
From: Navid Emamdoost @ 2019-10-04 19:09 UTC (permalink / raw)
  Cc: Daniel Vetter, David Airlie, Fabio Estevam, Sascha Hauer, kjlu,
	linux-kernel, dri-devel, emamd001, NXP Linux Team, Philipp Zabel,
	smccaman, Shawn Guo, Pengutronix Kernel Team, linux-arm-kernel,
	Navid Emamdoost

In imx_pd_bind, the duplicated memory for imxpd->edid via kmemdup should
be released in drm_of_find_panel_or_bridge or imx_pd_register fail.

Fixes: ebc944613567 ("drm: convert drivers to use drm_of_find_panel_or_bridge")
Fixes: 19022aaae677 ("staging: drm/imx: Add parallel display support")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/gpu/drm/imx/parallel-display.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
index e7ce17503ae1..9522d2cb0ad5 100644
--- a/drivers/gpu/drm/imx/parallel-display.c
+++ b/drivers/gpu/drm/imx/parallel-display.c
@@ -227,14 +227,18 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
 
 	/* port@1 is the output port */
 	ret = drm_of_find_panel_or_bridge(np, 1, 0, &imxpd->panel, &imxpd->bridge);
-	if (ret && ret != -ENODEV)
+	if (ret && ret != -ENODEV) {
+		kfree(imxpd->edid);
 		return ret;
+	}
 
 	imxpd->dev = dev;
 
 	ret = imx_pd_register(drm, imxpd);
-	if (ret)
+	if (ret) {
+		kfree(imxpd->edid);
 		return ret;
+	}
 
 	dev_set_drvdata(dev, imxpd);
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, back to index

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 19:09 [PATCH] drm/imx: fix memory leak in imx_pd_bind Navid Emamdoost
2019-10-05 15:02 ` Markus Elfring
2019-10-12 11:54   ` Markus Elfring
2019-10-12 19:22     ` Navid Emamdoost
2019-10-06  9:33 ` drm/imx: Checking a kmemdup() call in imx_pd_bind() Markus Elfring
2019-10-07  4:26   ` Navid Emamdoost
2019-10-07  7:44     ` Markus Elfring
2019-10-12  9:04     ` [PATCH 0/2] drm/imx: Adjustments for two functions Markus Elfring
2019-10-12  9:07       ` [PATCH 1/2] drm/imx: Fix error handling for a kmemdup() call in imx_pd_bind() Markus Elfring
2019-10-12 19:16         ` Navid Emamdoost
2019-10-12 19:24           ` Julia Lawall
2019-10-12  9:10       ` [PATCH 2/2] drm/imx: Fix error handling for a kmemdup() call in imx_ldb_panel_ddc() Markus Elfring

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git