[PORT FROM R2] Bluetooth: phone hang while transferring files via BT
authorOvidiu Beldie <ovidiux.beldie@intel.com>
Mon, 23 Jan 2012 13:28:09 +0000 (14:28 +0100)
committerbuildbot <buildbot@intel.com>
Wed, 25 Jan 2012 17:07:48 +0000 (09:07 -0800)
BZ: 8203 17106

Borqs-Id: bd3021797b4bc7d192a4cbae42375befbc79d84f
Borqs-Contact: b132 <stone.zhang@borqs.com>
Commit-Date: Wed Aug 24 10:40:33 PDT 2011

borqsbtx: 0004232
While receiving files via opp, turn on UMS mode and then turn UMS off. Phone hang appeared when
trying to receive a file again.
From log, there is a NULL pointer in l2cap_sock_sendmsg(). So handle the exception.

And add a log in headsetservice to track the connection performance.

Change-Id: I2ef19bd476dc601c9a314a00839817cc2b4cdb40
Orig-Change-Id: Idaed4e3b216192642f900b76f7a9ff66aa9636d8
Signed-off-by: Ovidiu Beldie <ovidiux.beldie@intel.com>
Reviewed-on: http://android.intel.com:8080/32735
Reviewed-by: Gross, Mark <mark.gross@intel.com>
Reviewed-by: Peix, FabienX <fabienx.peix@intel.com>
Tested-by: Zurmely, PierreX <pierrex.zurmely@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
net/bluetooth/l2cap_sock.c

index 61f1f62..92fa077 100644 (file)
@@ -686,10 +686,23 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
 
 static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len)
 {
-       struct sock *sk = sock->sk;
-       struct l2cap_chan *chan = l2cap_pi(sk)->chan;
+       struct sock *sk;
+       struct l2cap_chan *chan;
        int err;
 
+       if (!iocb || !sock || !msg || !sock->sk) {
+               BT_ERR("NULL pointer detected");
+               return -EINVAL;
+       }
+
+       sk = sock->sk;
+       chan = l2cap_pi(sk)->chan;
+
+       if (!chan) {
+               BT_ERR("NULL pointer detected");
+               return -EINVAL;
+       }
+
        BT_DBG("sock %p, sk %p", sock, sk);
 
        err = sock_error(sk);