Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 8912
b: refs/heads/master
c: 354d28d
h: refs/heads/master
v: v3
  • Loading branch information
Marcel Holtmann committed Sep 12, 2005
1 parent 84d8237 commit d4d5382
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 21d9e30ed020d24336cc3bee2a4e04da232ed554
refs/heads/master: 354d28d5f8546e115ebaae9311897f0bc4b6a8d4
30 changes: 25 additions & 5 deletions trunk/net/bluetooth/rfcomm/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
goto done;
}

if (sk->sk_type != SOCK_STREAM) {
err = -EINVAL;
goto done;
}

write_lock_bh(&rfcomm_sk_list.lock);

if (sa->rc_channel && __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr)) {
Expand Down Expand Up @@ -393,13 +398,17 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a
if (addr->sa_family != AF_BLUETOOTH || alen < sizeof(struct sockaddr_rc))
return -EINVAL;

if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND)
return -EBADFD;
lock_sock(sk);

if (sk->sk_type != SOCK_STREAM)
return -EINVAL;
if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) {
err = -EBADFD;
goto done;
}

lock_sock(sk);
if (sk->sk_type != SOCK_STREAM) {
err = -EINVAL;
goto done;
}

sk->sk_state = BT_CONNECT;
bacpy(&bt_sk(sk)->dst, &sa->rc_bdaddr);
Expand All @@ -410,6 +419,7 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a
err = bt_sock_wait_state(sk, BT_CONNECTED,
sock_sndtimeo(sk, flags & O_NONBLOCK));

done:
release_sock(sk);
return err;
}
Expand All @@ -428,6 +438,11 @@ static int rfcomm_sock_listen(struct socket *sock, int backlog)
goto done;
}

if (sk->sk_type != SOCK_STREAM) {
err = -EINVAL;
goto done;
}

if (!rfcomm_pi(sk)->channel) {
bdaddr_t *src = &bt_sk(sk)->src;
u8 channel;
Expand Down Expand Up @@ -472,6 +487,11 @@ static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int f
goto done;
}

if (sk->sk_type != SOCK_STREAM) {
err = -EINVAL;
goto done;
}

timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);

BT_DBG("sk %p timeo %ld", sk, timeo);
Expand Down

0 comments on commit d4d5382

Please sign in to comment.