git: 1b3f4ccb7dd8 - main - loader: we can only env_discard() existing variable
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 26 Feb 2024 12:58:24 UTC
The branch main has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=1b3f4ccb7dd8600d010fc6a09b09ee7d74872809 commit 1b3f4ccb7dd8600d010fc6a09b09ee7d74872809 Author: Toomas Soome <tsoome@FreeBSD.org> AuthorDate: 2024-02-25 22:34:00 +0000 Commit: Toomas Soome <tsoome@FreeBSD.org> CommitDate: 2024-02-26 12:56:52 +0000 loader: we can only env_discard() existing variable While dropping nvpair from nvstore, we also remove the corresponding environment variable. By doing so, we should be careful not to try to unset non-existing variable. Reviewed by: imp MFC after: 2 week Differential revision: https://reviews.freebsd.org/D44083 --- stand/libsa/zfs/zfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c index 3e7c698e650a..70a102f6425d 100644 --- a/stand/libsa/zfs/zfs.c +++ b/stand/libsa/zfs/zfs.c @@ -1264,8 +1264,12 @@ zfs_nvstore_unset_impl(void *vdev, const char *name, bool unset_env) rv = zfs_set_bootenv(vdev, spa->spa_bootenv); } - if (unset_env) - env_discard(env_getenv(name)); + if (unset_env) { + struct env_var *ev = env_getenv(name); + + if (ev != NULL) + env_discard(ev); + } return (rv); }