Skip to contentSkip to conversation

2.6.20-rc4: force fcntl(..., FASYNC) to return -EINVAL when f_op->fasync is NULL

PATCH New Dmitry Antipov 1 participant 1 message Jan 12, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6.20-rc4: force fcntl(..., FASYNC) to return -EINVAL when f_op->fasync is NULL

Hello,

this is a proposal fix needed to receive an error when the user requests 'fcntl(fd, F_SETFL, FASYNC)' but lower levels are too poor to handle this.

Dmitry

fs/fcntl.c +4 -4
@@ -236,11 +236,11 @@
 
 	lock_kernel();
 	if ((arg ^ filp->f_flags) & FASYNC) {
-		if (filp->f_op && filp->f_op->fasync) {
+		error = -EINVAL;
+		if (filp->f_op && filp->f_op->fasync)
 			error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
-			if (error < 0)
-				goto out;
-		}
+		if (error < 0)
+			goto out;
 	}
 
 	filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK);