mirror of
https://github.com/opnsense/src.git
synced 2026-04-23 15:19:31 -04:00
kern: mountroot: avoid fd leak in .md parsing
parse_dir_md() opens /dev/mdctl but only closes the resulting fd on success, not upon failure of the ioctl or when we exceed the md unit max. Reviewed by: kib (slightly previous version) Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #62 Differential Revision: https://reviews.freebsd.org/D31229
This commit is contained in:
parent
fa46a46a82
commit
23ecfa9d5b
1 changed files with 3 additions and 2 deletions
|
|
@ -580,6 +580,7 @@ parse_dir_md(char **conf)
|
|||
int error, fd, len;
|
||||
|
||||
td = curthread;
|
||||
fd = -1;
|
||||
|
||||
error = parse_token(conf, &tok);
|
||||
if (error)
|
||||
|
|
@ -635,9 +636,9 @@ parse_dir_md(char **conf)
|
|||
root_mount_mddev = mdio->md_unit;
|
||||
printf(MD_NAME "%u attached to %s\n", root_mount_mddev, mdio->md_file);
|
||||
|
||||
error = kern_close(td, fd);
|
||||
|
||||
out:
|
||||
if (fd >= 0)
|
||||
(void)kern_close(td, fd);
|
||||
free(mdio, M_TEMP);
|
||||
return (error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue