Module Name: src Committed By: riastradh Date: Sat Apr 22 14:23:32 UTC 2023
Modified Files: src/sys/kern: sys_descrip.c Log Message: fcntl(2), flock(2): Fix missing fd_putfile in error branch. Oops! To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/kern/sys_descrip.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/sys_descrip.c diff -u src/sys/kern/sys_descrip.c:1.43 src/sys/kern/sys_descrip.c:1.44 --- src/sys/kern/sys_descrip.c:1.43 Sat Apr 22 13:53:02 2023 +++ src/sys/kern/sys_descrip.c Sat Apr 22 14:23:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_descrip.c,v 1.43 2023/04/22 13:53:02 riastradh Exp $ */ +/* $NetBSD: sys_descrip.c,v 1.44 2023/04/22 14:23:32 riastradh Exp $ */ /*- * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.43 2023/04/22 13:53:02 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.44 2023/04/22 14:23:32 riastradh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -241,8 +241,10 @@ do_fcntl_lock(int fd, int cmd, struct fl if ((fp = fd_getfile(fd)) == NULL) return EBADF; - if ((fo_advlock = fp->f_ops->fo_advlock) == NULL) - return EINVAL; + if ((fo_advlock = fp->f_ops->fo_advlock) == NULL) { + error = EINVAL; + goto out; + } flg = F_POSIX; p = curproc; @@ -306,7 +308,7 @@ do_fcntl_lock(int fd, int cmd, struct fl break; } - fd_putfile(fd); +out: fd_putfile(fd); return error; } @@ -612,8 +614,10 @@ sys_flock(struct lwp *l, const struct sy if ((fp = fd_getfile(fd)) == NULL) return EBADF; - if ((fo_advlock = fp->f_ops->fo_advlock) == NULL) - return EOPNOTSUPP; + if ((fo_advlock = fp->f_ops->fo_advlock) == NULL) { + error = EOPNOTSUPP; + goto out; + } lf.l_whence = SEEK_SET; lf.l_start = 0; @@ -643,7 +647,7 @@ sys_flock(struct lwp *l, const struct sy } else { error = (*fo_advlock)(fp, fp, F_SETLK, &lf, F_FLOCK|F_WAIT); } - fd_putfile(fd); +out: fd_putfile(fd); return error; }