Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern fcntl(2), flock(2): Fix missing fd_putfile in error...
details: https://anonhg.NetBSD.org/src/rev/df4aa4b41fd9
branches: trunk
changeset: 374423:df4aa4b41fd9
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Apr 22 14:23:32 2023 +0000
description:
fcntl(2), flock(2): Fix missing fd_putfile in error branch.
Oops!
diffstat:
sys/kern/sys_descrip.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diffs (62 lines):
diff -r 7e909ed4d043 -r df4aa4b41fd9 sys/kern/sys_descrip.c
--- a/sys/kern/sys_descrip.c Sat Apr 22 14:05:36 2023 +0000
+++ b/sys/kern/sys_descrip.c Sat Apr 22 14:23:32 2023 +0000
@@ -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;
}
Home |
Main Index |
Thread Index |
Old Index