VisionFive2 Linux kernel

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

More than 9999 Commits   32 Branches   54 Tags
author: Richard W.M. Jones <rjones@redhat.com> 2012-10-09 15:27:43 +0100 committer: Al Viro <viro@zeniv.linux.org.uk> 2012-10-09 23:33:38 -0400 commit: aed976475bff939672b0e21595839c445dcec0fa parent: d1c7d97ad58836affde6e39980b96527510b572e
Commit Summary:
dup3: Return an error when oldfd == newfd.
Diffstat:
1 file changed, 3 insertions, 0 deletions
diff --git a/fs/file.c b/fs/file.c
index 0f1bda4bebfa..d3b5fa80b71b 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -922,6 +922,9 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
 	if ((flags & ~O_CLOEXEC) != 0)
 		return -EINVAL;
 
+	if (unlikely(oldfd == newfd))
+		return -EINVAL;
+
 	if (newfd >= rlimit(RLIMIT_NOFILE))
 		return -EMFILE;