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
This commit is contained in:
Toomas Soome 2024-02-26 00:34:00 +02:00
parent 8db56defa7
commit 1b3f4ccb7d

View file

@ -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);
}