]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[BLUETOOTH]: Use sockfd_put()
authorJulia Lawall <julia@diku.dk>
Tue, 8 Jan 2008 06:38:42 +0000 (22:38 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:00:48 +0000 (15:00 -0800)
The function sockfd_lookup uses fget on the value that is stored in
the file field of the returned structure, so fput should ultimately be
applied to this value.  This can be done directly, but it seems better
to use the specific macro sockfd_put, which does the same thing.

The problem was fixed using the following semantic patch.
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression s;
@@

   s = sockfd_lookup(...)
   ...
+  sockfd_put(s);
?- fput(s->file);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bluetooth/bnep/sock.c
net/bluetooth/cmtp/sock.c
net/bluetooth/hidp/sock.c

index 9ebd3c64474d916480506d20e2db8be6f1b30182..81065e548a1f50d4c4a37dd9c4c54f52726d7fdd 100644 (file)
@@ -94,7 +94,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
                        return err;
 
                if (nsock->sk->sk_state != BT_CONNECTED) {
-                       fput(nsock->file);
+                       sockfd_put(nsock);
                        return -EBADFD;
                }
 
@@ -103,7 +103,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
                        if (copy_to_user(argp, &ca, sizeof(ca)))
                                err = -EFAULT;
                } else
-                       fput(nsock->file);
+                       sockfd_put(nsock);
 
                return err;
 
index 783edab12ce82c024610b9dd3b91b9ee9f21ca3e..8c7f7bc4e0bacbbed7ef05daae6aacb0af34a8e3 100644 (file)
@@ -88,7 +88,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
                        return err;
 
                if (nsock->sk->sk_state != BT_CONNECTED) {
-                       fput(nsock->file);
+                       sockfd_put(nsock);
                        return -EBADFD;
                }
 
@@ -97,7 +97,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
                        if (copy_to_user(argp, &ca, sizeof(ca)))
                                err = -EFAULT;
                } else
-                       fput(nsock->file);
+                       sockfd_put(nsock);
 
                return err;
 
index 3292b956a7c491267d023ae5406561447a639810..f4dd02ca9a96d9acd1c73872aac795b6de68575b 100644 (file)
@@ -86,13 +86,13 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
 
                isock = sockfd_lookup(ca.intr_sock, &err);
                if (!isock) {
-                       fput(csock->file);
+                       sockfd_put(csock);
                        return err;
                }
 
                if (csock->sk->sk_state != BT_CONNECTED || isock->sk->sk_state != BT_CONNECTED) {
-                       fput(csock->file);
-                       fput(isock->file);
+                       sockfd_put(csock);
+                       sockfd_put(isock);
                        return -EBADFD;
                }
 
@@ -101,8 +101,8 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
                        if (copy_to_user(argp, &ca, sizeof(ca)))
                                err = -EFAULT;
                } else {
-                       fput(csock->file);
-                       fput(isock->file);
+                       sockfd_put(csock);
+                       sockfd_put(isock);
                }
 
                return err;