]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.22.14/fix-error-returns-in-sys_socketpair.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.22.14 / fix-error-returns-in-sys_socketpair.patch
1 From stable-bounces@linux.kernel.org Tue Nov 13 00:03:31 2007
2 From: David Miller <davem@davemloft.net>
3 Date: Tue, 13 Nov 2007 00:02:56 -0800 (PST)
4 Subject: Fix error returns in sys_socketpair()
5 To: stable@kernel.org
6 Cc: bunk@kernel.org
7 Message-ID: <20071113.000256.110812500.davem@davemloft.net>
8
9 From: David Miller <davem@davemloft.net>
10
11 patch bf3c23d171e35e6e168074a1514b0acd59cfd81a in mainline.
12
13 [NET]: Fix error reporting in sys_socketpair().
14
15 If either of the two sock_alloc_fd() calls fail, we
16 forget to update 'err' and thus we'll erroneously
17 return zero in these cases.
18
19 Based upon a report and patch from Rich Paul, and
20 commentary from Chuck Ebbert.
21
22 Signed-off-by: David S. Miller <davem@davemloft.net>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
24
25 ---
26 net/socket.c | 5 ++++-
27 1 file changed, 4 insertions(+), 1 deletion(-)
28
29 --- a/net/socket.c
30 +++ b/net/socket.c
31 @@ -1246,11 +1246,14 @@ asmlinkage long sys_socketpair(int famil
32 goto out_release_both;
33
34 fd1 = sock_alloc_fd(&newfile1);
35 - if (unlikely(fd1 < 0))
36 + if (unlikely(fd1 < 0)) {
37 + err = fd1;
38 goto out_release_both;
39 + }
40
41 fd2 = sock_alloc_fd(&newfile2);
42 if (unlikely(fd2 < 0)) {
43 + err = fd2;
44 put_filp(newfile1);
45 put_unused_fd(fd1);
46 goto out_release_both;