Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2552993ybp; Sat, 12 Oct 2019 12:25:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKgqdttTOfBwUAH6sBS0BldRSXJ0itrq2TvU2NN4L++Pqy4B8dgaW5amhYfnI+MjQnpVia X-Received: by 2002:a05:6402:1b1a:: with SMTP id by26mr20241966edb.178.1570908345930; Sat, 12 Oct 2019 12:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570908345; cv=none; d=google.com; s=arc-20160816; b=Pe56wPvJbeG5B2WgJ5zt7XEg840dm3TiL1hIG4xn7D+dn5AYltIHXUDeL2FoD6U7cP z4s7CEsRbulZYYnnoUQsPFgUi7aRjOhrNvzecjKnWEdqD1WdlgfOiy+//LX/MsV5CcN0 QuxgCVHtWnbEcFPKQGnB/XJm3Jci2IaXiUa5xVMKxnVbEGD7FVVioZOxA3OS6UA+iaVn lz2u2NtezIHcVmg6zvHnJ2efvD7gdIvbasOxXqpF/BcVJXCo4mZZlomzXZn9yCcJvkF9 /oCzQuVNTO0ubPWoqnauGUWhEuV73O05sK6VJ+syJWaCj+1LEbsCPnSV+NOWMbeNL3nl yUNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=cT4jgfzJeB6mjmeKwf2Yf5jA3F4AFpLEiFXYx4fMUFM=; b=G11UTLxmw4hFZvCEtvBBICKVNP5i3nGgSVf6PS6cTnxjwDs3C16QzEKZV64YjTGu3L NUZHG1SrYXbx4U8JfdtArWkC4VPFeqr0FwWuCPnj5u7tAZkv6KhVfBYQFfTDdZtyILgF tdtGI2HpwCPFqJO5hni+so4zpjIJJmEhr/sF+gOL8Vg5sskgNbqwn3XFhUSStJPJrRlU dFWTKi7FjWU+k8jdJRNsv2fn3PZesm3izv8Biugx3RUfJmz4IgsEhGNa44jWMXWwSuhz YD93qMmhcqzu09uf+KxZs4vfGslJwoyGoN7YJKZl0JbRwN5j/F+4NAZU1A6D+a3uNAau PWxw== 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 v9si7473217eju.406.2019.10.12.12.25.22; Sat, 12 Oct 2019 12:25:45 -0700 (PDT) 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 S1729687AbfJLTYX (ORCPT + 99 others); Sat, 12 Oct 2019 15:24:23 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:10410 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729384AbfJLTYX (ORCPT ); Sat, 12 Oct 2019 15:24:23 -0400 X-IronPort-AV: E=Sophos;i="5.67,289,1566856800"; d="scan'208";a="322500714" Received: from 81-65-53-202.rev.numericable.fr (HELO hadrien) ([81.65.53.202]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2019 21:24:19 +0200 Date: Sat, 12 Oct 2019 21:24:19 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Navid Emamdoost cc: Markus Elfring , dri-devel@lists.freedesktop.org, Pengutronix Kernel Team , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Daniel Vetter , David Airlie , Fabio Estevam , Philipp Zabel , Sascha Hauer , Shawn Guo , Peter Senna Tschudin , Navid Emamdoost , Kangjie Lu , Stephen McCamant , Rob Herring , Thierry Reding , LKML , kernel-janitors@vger.kernel.org Subject: Re: [PATCH 1/2] drm/imx: Fix error handling for a kmemdup() call in imx_pd_bind() In-Reply-To: Message-ID: References: <20191004190938.15353-1-navid.emamdoost@gmail.com> <540321eb-7699-1d51-59d5-dde5ffcb8fc4@web.de> <2abf545b-023b-853a-95ef-ce99e1896a5d@web.de> <3fd6aa8b-2529-7ff5-3e19-05267101b2a4@web.de> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-2018450889-1570908260=:3049" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-2018450889-1570908260=:3049 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Sat, 12 Oct 2019, Navid Emamdoost wrote: > On Sat, Oct 12, 2019 at 4:07 AM Markus Elfring wrote: > > > > From: Markus Elfring > > Date: Sat, 12 Oct 2019 10:30:21 +0200 > > > > The return value from a call of the function “kmemdup” was not checked > > in this function implementation. Thus add the corresponding error handling. > > > > Fixes: 19022aaae677dfa171a719e9d1ff04823ce65a65 ("staging: drm/imx: Add parallel display support") > > Signed-off-by: Markus Elfring > > --- > > drivers/gpu/drm/imx/parallel-display.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c > > index 35518e5de356..39c4798f56b6 100644 > > --- a/drivers/gpu/drm/imx/parallel-display.c > > +++ b/drivers/gpu/drm/imx/parallel-display.c > > @@ -210,8 +210,13 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data) > > return -ENOMEM; > > > > edidp = of_get_property(np, "edid", &imxpd->edid_len); > > - if (edidp) > > + if (edidp) { > > imxpd->edid = kmemdup(edidp, imxpd->edid_len, GFP_KERNEL); > > + if (!imxpd->edid) { > > + devm_kfree(dev, imxpd); > > You should not try to free imxpd here as it is a resource-managed > allocation via devm_kzalloc(). It means memory allocated with this > function is > automatically freed on driver detach. So, this patch introduces a double-free. No, it's not double freed since the proposed code frees it with a devm function, removing it from the list of things to free later. One can wonder why the free has to be made apparent, though. julia > > > + return -ENOMEM; > > + } > > + } > > > > ret = of_property_read_string(np, "interface-pix-fmt", &fmt); > > if (!ret) { > > -- > > 2.23.0 > > > > > -- > Navid. > --8323329-2018450889-1570908260=:3049--