patch-2.1.108 linux/fs/select.c

Next file: linux/fs/sysv/CHANGES
Previous file: linux/fs/proc/array.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.107/linux/fs/select.c linux/fs/select.c
@@ -297,21 +297,25 @@
 
 		current->state = TASK_INTERRUPTIBLE;
 		for (fdpnt = fds, j = 0; j < nfds; j++, fdpnt++) {
+			int fd;
 			unsigned int mask;
-			struct file * file;
 
-			mask = POLLNVAL;
-			/* poll_wait increments f_count if needed */
-			file = fcheck(fdpnt->fd);
-			if (file != NULL) {
-				mask = DEFAULT_POLLMASK;
-				if (file->f_op && file->f_op->poll)
-					mask = file->f_op->poll(file, wait);
-				mask &= fdpnt->events | POLLERR | POLLHUP;
-			}
-			if (mask) {
-				wait = NULL;
-				count++;
+			mask = 0;
+			fd = fdpnt->fd;
+			if (fd >= 0) {
+				/* poll_wait increments f_count if needed */
+				struct file * file = fcheck(fd);
+				mask = POLLNVAL;
+				if (file != NULL) {
+					mask = DEFAULT_POLLMASK;
+					if (file->f_op && file->f_op->poll)
+						mask = file->f_op->poll(file, wait);
+					mask &= fdpnt->events | POLLERR | POLLHUP;
+				}
+				if (mask) {
+					wait = NULL;
+					count++;
+				}
 			}
 			fdpnt->revents = mask;
 		}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov