Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Dec 2015 16:32:04 +0000 (UTC)
From:      Maksim Yevmenkin <emax@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r292660 - head/sys/netgraph/bluetooth/socket
Message-ID:  <201512231632.tBNGW4m8093030@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emax
Date: Wed Dec 23 16:32:04 2015
New Revision: 292660
URL: https://svnweb.freebsd.org/changeset/base/292660

Log:
  - grab ng_btsocket_l2cap_sockets_mtx lock in
    ng_btsocket_l2cap_process_l2ca_enc_change()
    before calling ng_btsocket_l2cap_pcb_by_cid();
  
  - handle possible NULL value returned from
    ng_btsocket_l2cap_pcb_by_cid();
  
  Submitted by:	Hans Petter Selasky; hps at selasky dot org
  MFC after:	1 week

Modified:
  head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c

Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
==============================================================================
--- head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c	Wed Dec 23 15:22:44 2015	(r292659)
+++ head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c	Wed Dec 23 16:32:04 2015	(r292660)
@@ -708,8 +708,15 @@ static int ng_btsocket_l2cap_process_l2c
 
 	op = (ng_l2cap_l2ca_enc_chg_op *)(msg->data);
 
+	mtx_lock(&ng_btsocket_l2cap_sockets_mtx);
+
 	pcb = ng_btsocket_l2cap_pcb_by_cid(&rt->src, op->lcid,
 					   op->idtype);
+	if (pcb == NULL) {
+		mtx_unlock(&ng_btsocket_l2cap_sockets_mtx);
+		return (ENOENT);
+	}
+
 	mtx_lock(&pcb->pcb_mtx);
 	pcb->encryption = op->result;
 	
@@ -729,6 +736,7 @@ static int ng_btsocket_l2cap_process_l2c
 		}
 	}
 	mtx_unlock(&pcb->pcb_mtx);
+	mtx_unlock(&ng_btsocket_l2cap_sockets_mtx);
 
 	return 0;
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512231632.tBNGW4m8093030>