Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp261168pxb; Fri, 15 Jan 2021 12:21:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2mcXz0njPN9YxAOzdsRjpfX9iNqs1TGbXSIs05hJSh3Fa6YUijGl61q51C/73Yqv8xjRC X-Received: by 2002:a17:906:6846:: with SMTP id a6mr5459423ejs.470.1610742059991; Fri, 15 Jan 2021 12:20:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610742059; cv=none; d=google.com; s=arc-20160816; b=Y7Qh8RCDmnplX32H+fxOYGFXXFJh85x97u+qp6XuD8Gmjja/J/j13cEbNbkA/T8rjZ 8YNAdFra7bInnAXGIohpjHahUuEhkdA1pJXdNlVShtrXXPWCU6f/iGC4jjNQlalCAawv X+caRpgbDLh2RgK95NATZqmkl+Sw+tQeCMDciPvj7TkaDDuvRtUKTX1EJjv/AJGH2ijq YoWkHcqQVyLjCPWoa9rDyiADQHqA8Ye68t4fCNjxZhi80Mk9HcBe6fEDpvoOCEA9uV7K QehlVEwBQvEeIJ08IuARR3bn7E8eP6fgwzj1hNLRszoD2lIe7DRF3G1gPQtnWIRb3Do0 Ikqw== 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=4wWmunBLyuIs0o2xSAuwDUDwEXBseMkt18FY9Z8O8EY=; b=EEUwGE6FWENOw7IOOdEcDmdqD1BGAEuRixZ6VCRWCA2sxOAfLgckkvomswdAJ58q05 KdustYLu7/bokQ4JWlWKBCbVg9g2OsGG9MejXokaetX3I7AKo6vIUIzWXBmCYnMAJI1b q4c23fd7KjmciRQC7NJ20rm+v4Fm63x2rEgOFm6F79CWxzBiho4slRWdjT0LcCocWMVS QLqE+kITpowGR60+zddiV0LULkzwb46/3w5bCywl2/IltrcnScRQ1hyyN5ENLK1aPSLO G36dl9Jc/VyMwY9rb21Qirx/XANPlverAZ6KmfUhUFPwC2Colm5ApeVznN+DtyIiPKvP IJZQ== 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 p5si4154340edj.169.2021.01.15.12.20.37; Fri, 15 Jan 2021 12:20:59 -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 S1733305AbhAOUTD (ORCPT + 99 others); Fri, 15 Jan 2021 15:19:03 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:35108 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726410AbhAOUTC (ORCPT ); Fri, 15 Jan 2021 15:19:02 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id B0B661C0B7C; Fri, 15 Jan 2021 21:18:19 +0100 (CET) Date: Fri, 15 Jan 2021 21:18:19 +0100 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Xiaolei Wang , Mark Brown Subject: Re: [PATCH 5.10 086/103] regmap: debugfs: Fix a memory leak when calling regmap_attach_dev Message-ID: <20210115201819.GA8375@amd> References: <20210115122006.047132306@linuxfoundation.org> <20210115122010.175920983@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline In-Reply-To: <20210115122010.175920983@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Xiaolei Wang >=20 > commit cffa4b2122f5f3e53cf3d529bbc74651f95856d5 upstream. >=20 > After initializing the regmap through > syscon_regmap_lookup_by_compatible, then regmap_attach_dev to the > device, because the debugfs_name has been allocated, there is no > need to redistribute it again ? redistribute? Anyway, this patch is clearly buggy: > =20 > if (!strcmp(name, "dummy")) { > - kfree(map->debugfs_name); > + if (!map->debugfs_name) > + kfree(map->debugfs_name); > =20 It runs kfree only if the variable is NULL. That's clearly useless, kfree(NULL) is NOP, and this causes memory leak. Best regards, Pavel --=20 http://www.livejournal.com/~pavelmachek --rwEMma7ioTxnRzrJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmAB+IoACgkQMOfwapXb+vLViACgpdacOys2yM71cP77OxHTSrOq yqwAniNDk0BPuDzWSUugYjfTU/gU3Laf =9C1+ -----END PGP SIGNATURE----- --rwEMma7ioTxnRzrJ--