Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp265562pxb; Fri, 15 Jan 2021 12:28:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/0lpEotNUhq6szVy2GGfmn/xf7OaGhd6qWhU2MMaqsbBB8tfY4Qetj/F2UTi61WLE2zDj X-Received: by 2002:a17:906:1c0c:: with SMTP id k12mr6098934ejg.354.1610742533497; Fri, 15 Jan 2021 12:28:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610742533; cv=none; d=google.com; s=arc-20160816; b=phCeRymCNBy2h0nutWcE5DcO7BtnSP8f7KeeSA/Z49CqR0r5o8HisxTXOfBdmIvF7W CKZS2kXyVpl7hNwPczNz7wswg3An0hmivPf1YxdZeomclRbCwwIQ4BvmJyAXcMGExyeE pkL7c0THI3V2rMF7o+4SbO5rSLDx2MGXLtLEBoQDi8HFxp0xqCi0IPbzIuVWUsbQpHWJ 1rITqWmgmO/LdkpvyNZfQtgUOito5XZijh+hiwbPRq198/2L8KKrxCo0UsvVLUxL0M3L Dx5N1IL1dt6oSOq8OUb2rsQvdU0SuIO0kLWtGCpXRZmzIYV6k4H4rgNhABXCyTX7ERe4 WE6Q== 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=bVkUDFaVXmkNXpgIUZLB/BM5ilWpmIdU7kA9W8Fh7+w=; b=aTuxptGJrO843E7DppbAMdI/OXpV9vH2RN/mekOeVky4M216ip3sXwuWPURSeO3IhV wvvzPCmC6eoxFIacWw0/8LhaNjWVkNK/QnFyYnlEvVkevK8BYQWsdj8mPaMlV+dGoqhQ Sgx7StixO6adOuR8adJNkE35Ci4SRfr84NEj3adJs3hjTJJjn8jZiRP8CLllxhbYR9Mc vufDP78R2hgeIv0dS0qqO89gkfc2bP8Mx6I4n6Yoqb/QmBvppnt22V7gj1uTksjlfMFh ncN5z1x5gp4j+uQKWYoA5qSJ854o/q6gYHJylUtdoN4kQ2KFNHe54TUeOIRkIJt+YlBt OtJA== 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 e26si5043910edr.610.2021.01.15.12.28.29; Fri, 15 Jan 2021 12:28:53 -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 S2387526AbhAOU1Y (ORCPT + 99 others); Fri, 15 Jan 2021 15:27:24 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:36936 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731529AbhAOU1X (ORCPT ); Fri, 15 Jan 2021 15:27:23 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 837A11C0B7C; Fri, 15 Jan 2021 21:26:40 +0100 (CET) Date: Fri, 15 Jan 2021 21:26:40 +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: <20210115202639.GB8375@amd> References: <20210115122006.047132306@linuxfoundation.org> <20210115122010.175920983@linuxfoundation.org> <20210115201819.GA8375@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="hQiwHBbRI9kgIhsi" Content-Disposition: inline In-Reply-To: <20210115201819.GA8375@amd> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --hQiwHBbRI9kgIhsi 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 >=20 > ? redistribute? >=20 > Anyway, this patch is clearly buggy: >=20 > > =20 > > if (!strcmp(name, "dummy")) { > > - kfree(map->debugfs_name); > > + if (!map->debugfs_name) > > + kfree(map->debugfs_name); > > =20 >=20 > It runs kfree only if the variable is NULL. That's clearly useless, > kfree(NULL) is NOP, and this causes memory leak. 103/ of the series fixes this up. Sorry for the noise...=20 Best regards, Pavel --=20 http://www.livejournal.com/~pavelmachek --hQiwHBbRI9kgIhsi Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmAB+n8ACgkQMOfwapXb+vJliACgpoeT7By9CujULzQaL50htqmR 4+YAoMKq6dpJulqr8R1fHSXL0kSysJyn =BVar -----END PGP SIGNATURE----- --hQiwHBbRI9kgIhsi--