VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
author: Oleg Nesterov <oleg@redhat.com> 2009-03-12 14:31:28 -0700 committer: Linus Torvalds <torvalds@linux-foundation.org> 2009-03-12 16:20:23 -0700 commit: e5bc49ba7439b9726006d031d440cba96819f0f8 parent: 8d0df7a3d1ecbaf5d5602a59055c8ca993855bed
Commit Summary:
pipe_rdwr_fasync: fix the error handling to prevent the leak/crash
Diffstat:
1 file changed, 4 insertions, 3 deletions
diff --git a/fs/pipe.c b/fs/pipe.c
index 3a48ba5179d5..14f502b89cf5 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -699,12 +699,12 @@ pipe_rdwr_fasync(int fd, struct file *filp, int on)
 	int retval;
 
 	mutex_lock(&inode->i_mutex);
-
 	retval = fasync_helper(fd, filp, on, &pipe->fasync_readers);
-
-	if (retval >= 0)
+	if (retval >= 0) {
 		retval = fasync_helper(fd, filp, on, &pipe->fasync_writers);
-
+		if (retval < 0) /* this can happen only if on == T */
+			fasync_helper(-1, filp, 0, &pipe->fasync_readers);
+	}
 	mutex_unlock(&inode->i_mutex);
 
 	if (retval < 0)