mac_veriexec_parser: Fix open_file error handling

NDFREE_PNBUF should be called after checking the return value of
vn_open(), and should only be called once.

Reviewed by: imp, zlei, Kornel Dulęba <mindal@semihalf.com>, Elliott Mitchell
Pull Request: https://github.com/freebsd/freebsd-src/pull/1338
This commit is contained in:
Heyang Zhou 2024-07-22 17:43:28 +00:00 committed by Warner Losh
parent 674b96f58b
commit 6e45b50342

View File

@ -241,9 +241,9 @@ open_file(const char *path, struct nameidata *nid)
NDINIT(nid, LOOKUP, 0, UIO_SYSSPACE, path); NDINIT(nid, LOOKUP, 0, UIO_SYSSPACE, path);
rc = vn_open(nid, &flags, 0, NULL); rc = vn_open(nid, &flags, 0, NULL);
NDFREE_PNBUF(nid);
if (rc != 0) if (rc != 0)
return (rc); return (rc);
NDFREE_PNBUF(nid);
return (0); return (0);
} }
@ -346,7 +346,6 @@ parse_entry(char *entry, char *prefix)
} }
rc = open_file(path, &nid); rc = open_file(path, &nid);
NDFREE_PNBUF(&nid);
if (rc != 0) if (rc != 0)
return (rc); return (rc);