kern_jail_set(): do not double-free opts

If vfs_buildopts() failed, vfs_freeopts() must not be called.

Reported and tested by:	pho
Reviewed by:	jamie
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D53612
This commit is contained in:
Konstantin Belousov
2025-11-06 07:50:42 +02:00
parent b558ebb082
commit 3f5f52216f
+5 -2
View File
@@ -1065,8 +1065,10 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
* than duplicate it under a different name.
*/
error = vfs_buildopts(optuio, &opts);
if (error)
if (error) {
opts = NULL;
goto done_free;
}
cuflags = flags & (JAIL_CREATE | JAIL_UPDATE);
if (!cuflags) {
@@ -2331,7 +2333,8 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
(void)kern_close(td, jfd_out);
if (g_path != NULL)
free(g_path, M_TEMP);
vfs_freeopts(opts);
if (opts != NULL)
vfs_freeopts(opts);
prison_free(mypr);
return (error);
}