patch-2.3.42 linux/fs/select.c

Next file: linux/include/asm-alpha/checksum.h
Previous file: linux/fs/qnx4/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.41/linux/fs/select.c linux/fs/select.c
@@ -414,11 +414,14 @@
 		wait = wait_table;
 	}
 
-	fds = (struct pollfd **)kmalloc(
-		(1 + (nfds - 1) / POLLFD_PER_PAGE) * sizeof(struct pollfd *),
-		GFP_KERNEL);
-	if (fds == NULL)
-		goto out;
+	fds = NULL;
+	if (nfds != 0) {
+		fds = (struct pollfd **)kmalloc(
+			(1 + (nfds - 1) / POLLFD_PER_PAGE) * sizeof(struct pollfd *),
+			GFP_KERNEL);
+		if (fds == NULL)
+			goto out;
+	}
 
 	nchunks = 0;
 	nleft = nfds;
@@ -467,7 +470,8 @@
 out_fds:
 	for (i=0; i < nchunks; i++)
 		free_page((unsigned long)(fds[i]));
-	kfree(fds);
+	if (nfds != 0)
+		kfree(fds);
 out:
 	if (wait)
 		free_wait(wait_table);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)