Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2548147ybp; Sat, 12 Oct 2019 12:20:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtnzERlG9XTeVl1hVmDGqx97wluYn/ezY0S5yZBqYhY0LubM6Nnd0GgzGN0FLOzgLFiWD1 X-Received: by 2002:a17:907:3301:: with SMTP id ym1mr20832624ejb.106.1570908000101; Sat, 12 Oct 2019 12:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570908000; cv=none; d=google.com; s=arc-20160816; b=CTnb636U7Vo4neXPZ6ToD0JOTRP6aYKJ+NkGa2EeRreXWfjJY+OMrHYnbsWcjfbr95 GzxXNf4x8BzLjwyG5FBOTP+wtX2odWEWqGHFied8EO8sqqkvahobPX59nvqpgKL+MS01 47mADqplyIYzkdkNRsisDCr0jEPufVQoDesETU/P0fm544DVDgJkfRWbz11y3hz74ruN RE+AWktPpGlhaVVYYtRPglT2DNM7AtY9KqsWDnq3QMtjxEtodo/XUrX2FLZQIXWuRke1 fHHD90AZj2SlwM3tZQYA1g8KsHzj9c3Bb084dnW1dLEf2COom0psFat23E0m0yOnnUnG FL8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=nnXOz+PRi58QoHjbu8c9O+WK1XkBB4tTUc2/yDJUsyM=; b=IlERzZz3yn9alqpnP4sM8W+FATj7qQuS+MrCB3dCUSJqoFzQvDXD2qI91pn4faL7lx PHxBsJBYR6QRd90plo5xnIuwLUfpEIk1BfPodDCaVov29eVG+5aqA214X32ENAWI+xUa W9qaxL1y5ibB2iaWotMandBfUORnoImJOqt2uPIUn0HqV0hmkwnahX5h1MGzh4/i+AB5 bQC2wJVdT9zeCj11oTuHWgw35eLzZzFPCYcWX6xtO8rtRF03VBw55pY+bc7w/EnJsG+U f/LVGY9DpcMV+X4guqwpQLNDfPxPmCpm3Sh/Ej2xYDTvwCJ/8qqHcb5aHq7Uqno3k6gH ReDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nS7hNDn8; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si8931384edb.371.2019.10.12.12.19.36; Sat, 12 Oct 2019 12:20:00 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nS7hNDn8; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729794AbfJLTRL (ORCPT + 99 others); Sat, 12 Oct 2019 15:17:11 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:37001 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729678AbfJLTRK (ORCPT ); Sat, 12 Oct 2019 15:17:10 -0400 Received: by mail-io1-f65.google.com with SMTP id b19so28561399iob.4; Sat, 12 Oct 2019 12:17:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=nnXOz+PRi58QoHjbu8c9O+WK1XkBB4tTUc2/yDJUsyM=; b=nS7hNDn8VxzSjURlBE78kATwaL7qPglBjODaQGeiluWc7L3KMJe9YDZ1nbMjCPg2k1 NmdpST3hzIfFgjjtm2k71t7RDTL5skpsie5QY7FAslM77IIOl0JgTi9qvN5Effnmvm4F QTb+x6j7CdtoOqx0Ko0vBaWDwGLJt3fUamR6zgAoIXZSs+BG6kUPAhNPbypt9dl0GbBi 6avvmlrRrLi3bU+ixPrRNh7CE6AxmSB4ZJTTTGxLBW8ymbvXkKkbKXHdhMDf3sn6Saua tCmiBnq8pNsZV5EM1pikTlxsuxSKlPYCnEuij0vSYKUvTLc171zWgrvQIwYl/pejOLK2 DmXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=nnXOz+PRi58QoHjbu8c9O+WK1XkBB4tTUc2/yDJUsyM=; b=sDG5bxhIBLDfZI5mxYUEmWfeW3th7DcKTP3Cwq3u0se8/60cmEVuo7PK1lVOcG/T6/ 0spyhpeBBjGcs+lHCMayXs4eyFlm1bdscu0vBERzplM4buFCBePfFXZGfk2MOaBCBhOa u2BtFuQhT+Mh2d/f/Hhti79/kG3vQjZ7PGv62KamnGiMcb1gYpa3bhC3PfHJo7KBSXva Lv6X+rZmj6OaKzNV5gHWzoY3RZ7LOaBvgcZorDgeV03v4TV4Xn78FdJrB15A4wMRerCk 04A+yMoJgUj5jNmgI1AWE9Gux2IILW5jF+pV6t5FYkiAo/dZtBtjCcvf2HuPMB7Z/9pN x7gg== X-Gm-Message-State: APjAAAVP/O3PHaCzRPdRHGy0z+RpbPBmB7oqkAOWD2mvm1kW3LAkjdIt n7qLm5ivd7zhskxmV7VUsNwHAn0PQQEPQ2Zfs1w= X-Received: by 2002:a02:a11e:: with SMTP id f30mr26789400jag.95.1570907829709; Sat, 12 Oct 2019 12:17:09 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <3fd6aa8b-2529-7ff5-3e19-05267101b2a4@web.de> From: Navid Emamdoost Date: Sat, 12 Oct 2019 14:16:58 -0500 Message-ID: Subject: Re: [PATCH 1/2] drm/imx: Fix error handling for a kmemdup() call in imx_pd_bind() To: Markus Elfring Cc: 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 12, 2019 at 4:07 AM Markus Elfring wrot= e: > > From: Markus Elfring > Date: Sat, 12 Oct 2019 10:30:21 +0200 > > The return value from a call of the function =E2=80=9Ckmemdup=E2=80=9D wa= s not checked > in this function implementation. Thus add the corresponding error handlin= g. > > Fixes: 19022aaae677dfa171a719e9d1ff04823ce65a65 ("staging: drm/imx: Add p= arallel 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 de= vice *master, void *data) > return -ENOMEM; > > edidp =3D of_get_property(np, "edid", &imxpd->edid_len); > - if (edidp) > + if (edidp) { > imxpd->edid =3D kmemdup(edidp, imxpd->edid_len, GFP_KERNE= L); > + 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-f= ree. > + return -ENOMEM; > + } > + } > > ret =3D of_property_read_string(np, "interface-pix-fmt", &fmt); > if (!ret) { > -- > 2.23.0 > --=20 Navid.