Merge tag 'v3.10.107' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / net / unix / af_unix.c
index 360954149888401df3834ac402c7fec28e554bd8..a14c213ea4270f6b2795afd3af7a40f13feb0360 100644 (file)
@@ -1001,6 +1001,7 @@ 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 = { NULL, NULL };
 
        err = -EINVAL;
        if (sunaddr->sun_family != AF_UNIX)
@@ -1016,9 +1017,20 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
                goto out;
        addr_len = err;
 
+       if (sun_path[0]) {
+               umode_t mode = S_IFSOCK |
+                      (SOCK_INODE(sock)->i_mode & ~current_umask());
+               err = unix_mknod(sun_path, mode, &path);
+               if (err) {
+                       if (err == -EEXIST)
+                               err = -EADDRINUSE;
+                       goto out;
+               }
+       }
+
        err = mutex_lock_interruptible(&u->readlock);
        if (err)
-               goto out;
+               goto out_put;
 
        err = -EINVAL;
        if (u->addr)
@@ -1035,17 +1047,6 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        atomic_set(&addr->refcnt, 1);
 
        if (sun_path[0]) {
-               struct path path;      
-
-               umode_t mode = S_IFSOCK |
-                      (SOCK_INODE(sock)->i_mode & ~current_umask());
-               err = unix_mknod(sun_path, mode, &path);
-               if (err) {
-                       if (err == -EEXIST)
-                               err = -EADDRINUSE;
-                       unix_release_addr(addr);
-                       goto out_up;
-               }
                addr->hash = UNIX_HASH_SIZE;
                hash = path.dentry->d_inode->i_ino & (UNIX_HASH_SIZE-1);
                spin_lock(&unix_table_lock);
@@ -1072,6 +1073,9 @@ out_unlock:
        spin_unlock(&unix_table_lock);
 out_up:
        mutex_unlock(&u->readlock);
+out_put:
+       if (err)
+               path_put(&path);
 out:
  
        return err;
@@ -1638,11 +1642,7 @@ static int unix_dgram_sendmsg(struct kiocb *kiocb, struct socket *sock,
        int max_level;
        int data_len = 0;
        int sk_locked;
-<<<<<<< HEAD
-        
-=======
 
->>>>>>> v3.10.95
        if (NULL == siocb->scm)
                siocb->scm = &tmp_scm;
        wait_for_unix_gc();
@@ -1734,13 +1734,9 @@ restart_locked:
                sock_put(other);
 
                if (!sk_locked)
-<<<<<<< HEAD
-               unix_state_lock(sk);
-=======
                        unix_state_lock(sk);
 
                err = 0;
->>>>>>> v3.10.95
                if (unix_peer(sk) == other) {
                        unix_peer(sk) = NULL;
                        unix_dgram_peer_wake_disconnect_wakeup(sk, other);
@@ -1770,16 +1766,12 @@ restart_locked:
                        goto out_unlock;
        }
 
-<<<<<<< HEAD
        /* other == sk && unix_peer(other) != sk if
         * - unix_peer(sk) == NULL, destination address bound to sk
         * - unix_peer(sk) == sk by time of get but disconnected before lock
         */
        if (other != sk &&
            unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {
-=======
-       if (unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {
->>>>>>> v3.10.95
                if (timeo) {
                        timeo = unix_wait_for_peer(other, timeo);