From: Johan Hedberg Date: Tue, 28 Jan 2014 23:16:50 +0000 (-0800) Subject: Bluetooth: Refuse peer RFCOMM address reading when not connected X-Git-Tag: v5.15~17544^2~11^2~7^2~45^2~263 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35364c99d20edc7329843e2a6dad6851d77eafd7;p=platform%2Fkernel%2Flinux-starfive.git Bluetooth: Refuse peer RFCOMM address reading when not connected When we're not connected the peer address information is undefined. This patch fixes the remote address getting to return a proper error in case the sate is anything else than BT_CONNECTED. Signed-off-by: Johan Hedberg Signed-off-by: Marcel Holtmann --- diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index fb8158a..00573fb 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -528,6 +528,9 @@ static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr, int * BT_DBG("sock %p, sk %p", sock, sk); + if (peer && sk->sk_state != BT_CONNECTED) + return -ENOTCONN; + memset(sa, 0, sizeof(*sa)); sa->rc_family = AF_BLUETOOTH; sa->rc_channel = rfcomm_pi(sk)->channel;