[BLUETOOTH]: Use sockfd_put()
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>
This commit is contained in:
parent
3becd578c5
commit
67b23219ce
|
@ -94,7 +94,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (nsock->sk->sk_state != BT_CONNECTED) {
|
if (nsock->sk->sk_state != BT_CONNECTED) {
|
||||||
fput(nsock->file);
|
sockfd_put(nsock);
|
||||||
return -EBADFD;
|
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)))
|
if (copy_to_user(argp, &ca, sizeof(ca)))
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
} else
|
} else
|
||||||
fput(nsock->file);
|
sockfd_put(nsock);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (nsock->sk->sk_state != BT_CONNECTED) {
|
if (nsock->sk->sk_state != BT_CONNECTED) {
|
||||||
fput(nsock->file);
|
sockfd_put(nsock);
|
||||||
return -EBADFD;
|
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)))
|
if (copy_to_user(argp, &ca, sizeof(ca)))
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
} else
|
} else
|
||||||
fput(nsock->file);
|
sockfd_put(nsock);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
|
@ -86,13 +86,13 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
|
||||||
|
|
||||||
isock = sockfd_lookup(ca.intr_sock, &err);
|
isock = sockfd_lookup(ca.intr_sock, &err);
|
||||||
if (!isock) {
|
if (!isock) {
|
||||||
fput(csock->file);
|
sockfd_put(csock);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (csock->sk->sk_state != BT_CONNECTED || isock->sk->sk_state != BT_CONNECTED) {
|
if (csock->sk->sk_state != BT_CONNECTED || isock->sk->sk_state != BT_CONNECTED) {
|
||||||
fput(csock->file);
|
sockfd_put(csock);
|
||||||
fput(isock->file);
|
sockfd_put(isock);
|
||||||
return -EBADFD;
|
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)))
|
if (copy_to_user(argp, &ca, sizeof(ca)))
|
||||||
err = -EFAULT;
|
err = -EFAULT;
|
||||||
} else {
|
} else {
|
||||||
fput(csock->file);
|
sockfd_put(csock);
|
||||||
fput(isock->file);
|
sockfd_put(isock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Reference in New Issue