af_unix.c: fix the compile warning in unix_bind
Subsystems (3)
PATCH 1/1 af_unix.c: fix the compile warning in unix_bind
--- net/unix/af_unix.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
net/unix/af_unix.c +6 -3
@@ -860,6 +860,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)unsigned int hash;struct unix_address *addr;struct hlist_head *list; +struct path path; +umode_t mode; err = -EINVAL ;if (sunaddr->sun_family !=AF_UNIX )
@@ -890,11 +892,12 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) addr->len = addr_len; addr->hash = hash ^ sk->sk_type;atomic_set (&addr->refcnt,1 ); - +if (sun_path[0 ]) { -struct path path; -umode_t mode =S_IFSOCK | + mode =S_IFSOCK | (SOCK_INODE (sock)->i_mode & ~current_umask ()); + +memset (&path,0 ,sizeof (path)); err =unix_mknod (sun_path, mode, &path);if (err) {if (err == -EEXIST )
Signature · 1 line
1.7.5.4
David Miller
maintainerFrom: Jing Wang <[email protected]>
Date: Fri, 26 Oct 2012 10:48:47 +0800
Quoted 2 lines
Signed-off-by Jing Wang <[email protected]>
What compile warning? You need to describe what problem you are solving, rather than assume we can figure it out by reading your patch.
Review
Quoted 2 lines
(quoted diff) +1
-1- +
This doesn't do anything and should be in your patch.
Thanks for your review and i'm sorry about this, the warning is :
CC net/unix/af_unix.onet/unix/af_unix.c: In function 'unix_bind':net/unix/af_unix.c:895: warning: 'path.dentry' may be used uninitialized in this function net/unix/af_unix.c:895: warning: 'path.mnt' may be used uninitialized in this function
Quoted 11 lines · David Miller
From: Jing Wang <[email protected]>
Date: Fri, 26 Oct 2012 10:48:47 +0800Quoted 1 line
Signed-off-by Jing Wang <[email protected]>What compile warning? You need to describe what problem you are solving, rather than assume we can figure it out by reading your patch.
Review
Quoted 2 lines
(quoted diff) +1
-1- +This doesn't do anything and should be in your patch.
Quoted 10 lines · Jing Wang
Signed-off-by Jing Wang <[email protected]>--- net/unix/af_unix.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)net/unix/af_unix.c +0
-0
net/unix/af_unix.c static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · line 864
Quoted 5 lines
net/unix/af_unix.c +2
-0@@ -860,6 +860,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)unsigned int hash;struct unix_address *addr;struct hlist_head *list; +struct path path; +umode_t mode;
This code motion to the top level in the function is also wrong.
Quoted 8 lines
net/unix/af_unix.c +1
-1err = -EINVAL ;if (sunaddr->sun_family !=AF_UNIX )@@ -890,11 +892,12 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) addr->len = addr_len; addr->hash = hash ^ sk->sk_type;atomic_set (&addr->refcnt,1 ); - +
net/unix/af_unix.c static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · line 903
Quoted 10 lines
net/unix/af_unix.c +3
-2if (sun_path[0 ]) { -struct path path; -umode_t mode =S_IFSOCK | + mode =S_IFSOCK | (SOCK_INODE (sock)->i_mode & ~current_umask ()); + +memset (&path,0 ,sizeof (path)); err =unix_mknod (sun_path, mode, &path);if (err) {if (err == -EEXIST )
Eric