summaryrefslogtreecommitdiff
path: root/sys/compat/linux
diff options
context:
space:
mode:
authorjdolecek <jdolecek@NetBSD.org>2003-06-29 14:51:28 +0000
committerjdolecek <jdolecek@NetBSD.org>2003-06-29 14:51:28 +0000
commitdc63267c8b0dab02512fecb09a80be141f9c8398 (patch)
treeaeb5976986cb4a24891e67f458eff61bf5151a3d /sys/compat/linux
parent6721e83cfc42f40ac0c115485ec873398a07af8c (diff)
properly FILE_USE/FILE_UNUSE descriptor in linux_sys_fcntl()
adresses PR kern/21628 by Wolfgang Solfrank
Diffstat (limited to 'sys/compat/linux')
-rw-r--r--sys/compat/linux/common/linux_file.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/compat/linux/common/linux_file.c b/sys/compat/linux/common/linux_file.c
index 6bc003cc424..6d8e3f8aba5 100644
--- a/sys/compat/linux/common/linux_file.c
+++ b/sys/compat/linux/common/linux_file.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_file.c,v 1.59 2003/06/28 14:21:21 darrenr Exp $ */
+/* $NetBSD: linux_file.c,v 1.60 2003/06/29 14:51:28 jdolecek Exp $ */
/*-
* Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.59 2003/06/28 14:21:21 darrenr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.60 2003/06/29 14:51:28 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -427,8 +427,14 @@ linux_sys_fcntl(l, v, retval)
fdp = p->p_fd;
if ((fp = fd_getfile(fdp, fd)) == NULL)
return EBADF;
- /* FILE_USE() not needed here */
- if (fp->f_type != DTYPE_VNODE) {
+ FILE_USE(fp);
+
+ /* Check it's a character device vnode */
+ if (fp->f_type != DTYPE_VNODE
+ || (vp = (struct vnode *)fp->f_data) == NULL
+ || vp->v_type != VCHR) {
+ FILE_UNUSE(fp, l);
+
not_tty:
/* Not a tty, proceed with common fcntl() */
cmd = cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
@@ -436,11 +442,13 @@ linux_sys_fcntl(l, v, retval)
}
/* check that the vnode is a tty */
- vp = (struct vnode *)fp->f_data;
- if (vp->v_type != VCHR)
- goto not_tty;
- if ((error = VOP_GETATTR(vp, &va, p->p_ucred, l)))
+ error = VOP_GETATTR(vp, &va, p->p_ucred, l);
+
+ FILE_UNUSE(fp, l); /* Don't need anymore */
+
+ if (error)
return error;
+
cdev = cdevsw_lookup(va.va_rdev);
if (cdev == NULL)
return (ENXIO);