Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2056571pxu; Tue, 24 Nov 2020 16:05:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvEEqWjcRnStegutj1PchpYlDEykDzut+gR3WWE3GRUKDu96qwI5mjHOofdvjT3cQL/Dkh X-Received: by 2002:a17:906:b799:: with SMTP id dt25mr910590ejb.88.1606262714668; Tue, 24 Nov 2020 16:05:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606262714; cv=none; d=google.com; s=arc-20160816; b=GU01u+6N/qwqPr/uiaRPmQ/9whpHKb05wkl/JcFaVhxRHklA6c+GSN4zZMhEYA/B71 hyvq3NTVTWiHkkNTdr23mt8wL9iVY5YAkZcNeQQHpERsHm1wEyNPVZ3CKyFLRjQMSh6x mfwlqqjI3MQsnmZUgtVB+qd0yybASl54BMY4jp58Y9YfKGH32rT/mb5yNAzw1qAE8u8Z WdT5WRnTUDNX/97ft1PBtz4yHBpyCx3m60fpeEAF/n8DWfLUngTyu7wsNeKywvHcKS75 WdRihbMm2a5vUR91QLp/DzCi0vHCJaxCZe5+LlE+MP5dSFAS3RjFZ2c5FL7c8ItZEiFC B81A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=TemlO3OqzZNBLBHloCpcroG6C+p/RWYYtV6kRcNqQsM=; b=BkWnwlRGIPsP7wwiNIuCmEdGMbTQLWYktRelGTvCP+sT5LMxLdlXMuo298y5FC75K5 ebOkJxdUdVdIfZpvQ77qDKV7p2mVIiTy7omRClC15FRtYTXAFbyaLbvAeVxynxfM0mxx 6peIlCcIZUxJLKqHvVazdyXZ7aXz9ht5FdwZttTG+CGPfqkxA3iii7lWhApPUAsRs9Bk T5nOWX72doXYoxOnTXAjAauD6BgcvdShXpVWR0LjFT253gWwjn9/fnvLLHl428X0viLs kJ1+IQQL1cOZtps33OTVqsMZSKqFOpZTfOR8DSABHe7fErYU9dc3zxw+ASmYScqtVrGj brDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lz6si293053ejb.116.2020.11.24.16.04.48; Tue, 24 Nov 2020 16:05:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729076AbgKXWwl (ORCPT + 99 others); Tue, 24 Nov 2020 17:52:41 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:48978 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729045AbgKXWwk (ORCPT ); Tue, 24 Nov 2020 17:52:40 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 442061C0B78; Tue, 24 Nov 2020 23:52:38 +0100 (CET) Date: Tue, 24 Nov 2020 23:52:37 +0100 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Zhang Qilong , Marc Kleine-Budde , Sasha Levin Subject: Re: [PATCH 4.19 51/91] can: ti_hecc: Fix memleak in ti_hecc_probe Message-ID: <20201124225237.GA12731@amd> References: <20201123121809.285416732@linuxfoundation.org> <20201123121811.803791718@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EeQfGwPcQSOJBaQU" Content-Disposition: inline In-Reply-To: <20201123121811.803791718@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Zhang Qilong >=20 > [ Upstream commit 7968c7c79d3be8987feb8021f0c46e6866831408 ] >=20 > In the error handling, we should goto the probe_exit_candev > to free ndev to prevent memory leak. Well, that's true. Unfortunately, 4.19 version has way more exit paths than mainline, so the fix is not nearly complete. Mainline code is fragile but okay. > Fixes: dabf54dd1c63 ("can: ti_hecc: Convert TI HECC driver to DT only dr= iver") I'm pretty sure problems were there before this commit. Signed-off-by: Pavel Machek (CIP) Best regards, Pavel diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c index 81a3fdd5e010..4400a1a7dbd0 100644 --- a/drivers/net/can/ti_hecc.c +++ b/drivers/net/can/ti_hecc.c @@ -897,7 +897,8 @@ static int ti_hecc_probe(struct platform_device *pdev) res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc"); if (!res) { dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc\n"); - return -EINVAL; + err =3D -EINVAL; + goto probe_exit_candev; } =20 priv->base =3D devm_ioremap_resource(&pdev->dev, res); @@ -911,7 +912,8 @@ static int ti_hecc_probe(struct platform_device *pdev) res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc-ram"); if (!res) { dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc-ram\n"); - return -EINVAL; + err =3D -EINVAL; + goto probe_exit_candev; } =20 priv->hecc_ram =3D devm_ioremap_resource(&pdev->dev, res); @@ -925,7 +927,8 @@ static int ti_hecc_probe(struct platform_device *pdev) res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "mbx"); if (!res) { dev_err(&pdev->dev, "can't get IORESOURCE_MEM mbx\n"); - return -EINVAL; + err =3D -EINVAL; + goto probe_exit_candev; } =20 priv->mbx =3D devm_ioremap_resource(&pdev->dev, res); --=20 http://www.livejournal.com/~pavelmachek --EeQfGwPcQSOJBaQU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl+9jrUACgkQMOfwapXb+vJHNACeNctpl4WEfuB6GoxNeoOUzoyd UM4AoI+9QA0ioS3HzbwnGuycX8Vclzpm =Pwpl -----END PGP SIGNATURE----- --EeQfGwPcQSOJBaQU--