From nobody Fri Oct 8 06:10:40 2021 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 5466E12D2FCA; Fri, 8 Oct 2021 06:10:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HQd8z3D3Fz3L38; Fri, 8 Oct 2021 06:10:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7D18C21ED2; Fri, 8 Oct 2021 06:10:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1986AeMf007025; Fri, 8 Oct 2021 06:10:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1986AeOb007024; Fri, 8 Oct 2021 06:10:40 GMT (envelope-from git) Date: Fri, 8 Oct 2021 06:10:40 GMT Message-Id: <202110080610.1986AeOb007024@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 3f92fa796181 - stable/12 - loader: strdup name strings from dataset walker 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 3f92fa796181e754ca930e3e5f8a84db25b9d432 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=3f92fa796181e754ca930e3e5f8a84db25b9d432 commit 3f92fa796181e754ca930e3e5f8a84db25b9d432 Author: Toomas Soome AuthorDate: 2020-03-28 21:50:27 +0000 Commit: Kyle Evans CommitDate: 2021-10-08 02:42:32 +0000 loader: strdup name strings from dataset walker The removal of zfs scratch buffer did miss the fact the dataset lookup was picking up the names from zap list. (cherry picked from commit 215597f05fc6cf9e218d26ef37063ec58451a259) --- stand/libsa/zfs/zfs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c index f54e68de578c..9bcf4b35a84e 100644 --- a/stand/libsa/zfs/zfs.c +++ b/stand/libsa/zfs/zfs.c @@ -92,7 +92,7 @@ static int zfs_env_count; SLIST_HEAD(zfs_be_list, zfs_be_entry) zfs_be_head = SLIST_HEAD_INITIALIZER(zfs_be_head); struct zfs_be_list *zfs_be_headp; struct zfs_be_entry { - const char *name; + cha *name; SLIST_ENTRY(zfs_be_entry) entries; } *zfs_be, *zfs_be_tmp; @@ -920,6 +920,7 @@ zfs_bootenv_initial(const char *name) while (!SLIST_EMPTY(&zfs_be_head)) { zfs_be = SLIST_FIRST(&zfs_be_head); SLIST_REMOVE_HEAD(&zfs_be_head, entries); + free(zfs_be->name); free(zfs_be); } @@ -987,6 +988,7 @@ zfs_bootenv(const char *name) while (!SLIST_EMPTY(&zfs_be_head)) { zfs_be = SLIST_FIRST(&zfs_be_head); SLIST_REMOVE_HEAD(&zfs_be_head, entries); + free(zfs_be->name); free(zfs_be); } @@ -1006,7 +1008,11 @@ zfs_belist_add(const char *name, uint64_t value __unused) if (zfs_be == NULL) { return (ENOMEM); } - zfs_be->name = name; + zfs_be->name = strdup(name); + if (zfs_be->name == NULL) { + free(zfs_be); + return (ENOMEM); + } SLIST_INSERT_HEAD(&zfs_be_head, zfs_be, entries); zfs_env_count++;