[PATCH] -EINVAL if no fasync op for file

From: Dmitry Antipov
Date: Thu Oct 18 2007 - 05:50:29 EST


This patch proposes an additional error checking performed within setfl().

As a result, fcntl (fd, F_SETFL, O_ASYNC) will return -1 and set errno
to -EINVAL if filp->f_op->fasync is NULL for file specified by fd. This
is possible, for example, if fd is a descriptor returned by inotify_init().


Dmitry

Signed-off-by: Dmitry Antipov <antipov@xxxxxxxxxxxxx>

--- .orig-2.6.23/fs/fcntl.c 2007-10-17 15:26:06.000000000 +0400
+++ 2.6.23/fs/fcntl.c 2007-10-17 15:25:27.000000000 +0400
@@ -240,6 +240,9 @@
error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
if (error < 0)
goto out;
+ } else {
+ error = -EINVAL;
+ goto out;
}
}