提交 4387ff75 编写于 作者: D David S. Miller

[NET]: Fix net/socket.c warnings.

GCC (correctly) says:

net/socket.c: In function ‘sys_sendto’:
net/socket.c:1510: warning: ‘err’ may be used uninitialized in this function
net/socket.c: In function ‘sys_recvfrom’:
net/socket.c:1571: warning: ‘err’ may be used uninitialized in this function

sock_from_file() either returns filp->private_data or it
sets *err and returns NULL.

Callers return "err" on NULL, but filp->private_data could
be NULL.

Some minor rearrangements of error handling in sys_sendto
and sys_recvfrom solves the issue.
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 23bb80d2
...@@ -1514,8 +1514,9 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len, ...@@ -1514,8 +1514,9 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len,
struct file *sock_file; struct file *sock_file;
sock_file = fget_light(fd, &fput_needed); sock_file = fget_light(fd, &fput_needed);
err = -EBADF;
if (!sock_file) if (!sock_file)
return -EBADF; goto out;
sock = sock_from_file(sock_file, &err); sock = sock_from_file(sock_file, &err);
if (!sock) if (!sock)
...@@ -1542,6 +1543,7 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len, ...@@ -1542,6 +1543,7 @@ asmlinkage long sys_sendto(int fd, void __user *buff, size_t len,
out_put: out_put:
fput_light(sock_file, fput_needed); fput_light(sock_file, fput_needed);
out:
return err; return err;
} }
...@@ -1573,12 +1575,13 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size, ...@@ -1573,12 +1575,13 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size,
int fput_needed; int fput_needed;
sock_file = fget_light(fd, &fput_needed); sock_file = fget_light(fd, &fput_needed);
err = -EBADF;
if (!sock_file) if (!sock_file)
return -EBADF; goto out;
sock = sock_from_file(sock_file, &err); sock = sock_from_file(sock_file, &err);
if (!sock) if (!sock)
goto out; goto out_put;
msg.msg_control = NULL; msg.msg_control = NULL;
msg.msg_controllen = 0; msg.msg_controllen = 0;
...@@ -1597,8 +1600,9 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size, ...@@ -1597,8 +1600,9 @@ asmlinkage long sys_recvfrom(int fd, void __user *ubuf, size_t size,
if (err2 < 0) if (err2 < 0)
err = err2; err = err2;
} }
out: out_put:
fput_light(sock_file, fput_needed); fput_light(sock_file, fput_needed);
out:
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册