Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4646271pja; Thu, 21 Nov 2019 23:26:24 -0800 (PST) X-Google-Smtp-Source: APXvYqyqZGaRKoMkB6t//ivkLlXHsJFQWZtRpHMRiFQP7QM6jtCKHNhlP0ryIy0A/cOJ2zGloxVU X-Received: by 2002:a17:906:524f:: with SMTP id y15mr12567647ejm.3.1574407584260; Thu, 21 Nov 2019 23:26:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574407584; cv=none; d=google.com; s=arc-20160816; b=Ecy1GNiBlqXVvDs72ZR9B25YRGDa6nYnKAnALMS8evusQHB7dYb080bg7aAIKhaCOB oNk+n9QwBuUQPpPCysOIpg0IF1wfxsvZQG19Pc3AYi4JcsNa4k0IlTee5Wnbl3t5YgW/ B/Ff+gE0t9v9wiMpXXMzCziXYRS9UOCUdCHVZizQV2HBUBuaE3F0eg8Ntrzuz5qSeYS1 uVEKAzjRmqYu/0WnuBfEdveDkZFwg2hj+Ph81sYdsOFMihtfOb6k2FZfNtQHEMxaQEpf R/B0E7+IbYEYCaS6bWjYEFwLJX6uPzA07WUy4bZmOWwinMDtreOeijQdXBHNzabsccUd BVbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=YWD4OVlJHggbaQskxoMdvCGsshWhB4eleKdaX/Wp5SQ=; b=roerFgBZxQ03mByQf1JGmShEv0J9SqFP+gtj7c1OfM5JRQJFceGCA6Yio4gRMvDgqW Xo1HoqbnRlFmQxTAQxrHjAR2t5X77i4V0JPHxWVV9dZu71KzNt4smXGDX7FLMnrj5Cm2 +wSEITiUiFORN/iMyy1OaPeK6FVb/PMRbGr9mK78Oqy6/6ugBk88ItYeFhqe8XkTSnYj GwLXJsVdgfClF2Y+zCH2vNGvvEXyLwBEWFVo8x+FMzvYdf78Cn/osdJVjugcGJcOKs1D SSabZKcnCzK3al6YNm2kItGxNEJVih/assW5f1ZihG7KQvBRA/YLxCOQCQrT0nKdokFI ZQQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10si5272287edj.316.2019.11.21.23.25.56; Thu, 21 Nov 2019 23:26:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbfKVHWr (ORCPT + 99 others); Fri, 22 Nov 2019 02:22:47 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:45925 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726018AbfKVHWq (ORCPT ); Fri, 22 Nov 2019 02:22:46 -0500 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iY3H9-0000om-N2; Fri, 22 Nov 2019 08:22:43 +0100 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iY3H5-0001Uh-II; Fri, 22 Nov 2019 08:22:39 +0100 Date: Fri, 22 Nov 2019 08:22:39 +0100 From: Marco Felsch To: Navid Emamdoost Cc: Philipp Zabel , David Airlie , Daniel Vetter , Sascha Hauer , Shawn Guo , Fabio Estevam , LKML , dri-devel@lists.freedesktop.org, Navid Emamdoost , NXP Linux Team , Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] drm/imx: fix memory leak in imx_pd_bind Message-ID: <20191122072239.dhbhi2uawoqsclwy@pengutronix.de> References: <20191004190938.15353-1-navid.emamdoost@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 08:19:40 up 6 days, 22:38, 23 users, load average: 0.00, 0.00, 0.00 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Navid, On 19-11-21 12:31, Navid Emamdoost wrote: > On Fri, Oct 4, 2019 at 2:09 PM Navid Emamdoost > wrote: > > > > 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 > > --- > > Would you please review this patch? > > Thanks, I currently work on the drm/imx driver(s) to avoid errors like [1]. Hopefully I have a working version till next week. There I fixed this issue by using the devm_kmemdup() and dropped the explicit kfree() within unbind(). [1] https://www.spinics.net/lists/dri-devel/msg189388.html Regards, Marco > > > 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 > > > > > -- > Navid. > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |