From nobody Sun Aug 10 23:28:50 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4c0Yr35xJ7z63XqN; Sun, 10 Aug 2025 23:29:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4c0Yr31YXLz3gvb; Sun, 10 Aug 2025 23:29:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 57ANSpIq017505; Mon, 11 Aug 2025 02:28:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 57ANSpIq017505 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 57ANSoQE017504; Mon, 11 Aug 2025 02:28:50 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 11 Aug 2025 02:28:50 +0300 From: Konstantin Belousov To: Warner Losh Cc: Warner Losh , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: bc598959090d - main - autofs: Plug memory leak Message-ID: References: <202508100156.57A1uMoa022605@gitrepo.freebsd.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Rspamd-Queue-Id: 4c0Yr31YXLz3gvb X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] On Sun, Aug 10, 2025 at 04:43:55PM -0600, Warner Losh wrote: > On Sat, Aug 9, 2025 at 11:19 PM Konstantin Belousov wrote: > > > > On Sun, Aug 10, 2025 at 01:56:22AM +0000, Warner Losh wrote: > > > The branch main has been updated by imp: > > > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=bc598959090d43aa0fc6b91355979016a9449041 > > > > > > commit bc598959090d43aa0fc6b91355979016a9449041 > > > Author: Enji Cooper > > > AuthorDate: 2025-08-10 01:52:31 +0000 > > > Commit: Warner Losh > > > CommitDate: 2025-08-10 01:54:42 +0000 > > > > > > autofs: Plug memory leak > > > > > > Originally, this was an extra free, but ngie@ suggested this > > > change. Since that's the whole thing, I've set her as the author for > > > this ancient review instead of trix@juniper.net. > > > > > > Sugggested by: ngie > > > Differential Revision: https://reviews.freebsd.org/D10063 > > > Sponsored by: Netflix > > > --- > > > usr.sbin/autofs/common.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c > > > index 18756752876c..6b98214162ae 100644 > > > --- a/usr.sbin/autofs/common.c > > > +++ b/usr.sbin/autofs/common.c > > > @@ -149,7 +149,7 @@ create_directory(const char *path) > > > error = mkdir(partial, 0755); > > > if (error != 0 && errno != EEXIST) { > > > log_warn("cannot create %s", partial); > > > - return; > > > + break; > > > } > > > } > > > > > Isn't there another leak, occuring when the first break in the loop is taken? > > Then the 'partial' duped string is not freed. > > I think it's always leaked. checked_strdup allocates it, then concat > allocates a new string that's set to partial. So no matter what, we > should free it, no? > > Eg > diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c > index 6b98214162ae..2dd7c290cebc 100644 > --- a/usr.sbin/autofs/common.c > +++ b/usr.sbin/autofs/common.c > @@ -153,6 +153,7 @@ create_directory(const char *path) > } > } > > + free(partial); > free(tofree); > } > I think this is right.