diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2015-02-03 03:01:13 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-02-03 03:02:12 -0500 |
commit | 88d9077c27d0c1a7c022d9dc987640beecf23560 (patch) | |
tree | 0e72093db43abd243deaf2bdaf054262e7694feb | |
parent | 8f0c304c693c5a9759ed6ae50d07d4590dad5ae7 (diff) |
Bluetooth: Fix potential NULL dereference
The bnep_get_device function may be triggered by an ioctl just after a
connection has gone down. In such a case the respective L2CAP chan->conn
pointer will get set to NULL (by l2cap_chan_del). This patch adds a
missing NULL check for this case in the bnep_get_device() function.
Reported-by: Patrik Flykt <patrik.flykt@linux.intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | net/bluetooth/bnep/core.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index ce82722d049b..05f57e491ccb 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
@@ -511,13 +511,12 @@ static int bnep_session(void *arg) | |||
511 | 511 | ||
512 | static struct device *bnep_get_device(struct bnep_session *session) | 512 | static struct device *bnep_get_device(struct bnep_session *session) |
513 | { | 513 | { |
514 | struct hci_conn *conn; | 514 | struct l2cap_conn *conn = l2cap_pi(session->sock->sk)->chan->conn; |
515 | 515 | ||
516 | conn = l2cap_pi(session->sock->sk)->chan->conn->hcon; | 516 | if (!conn || !conn->hcon) |
517 | if (!conn) | ||
518 | return NULL; | 517 | return NULL; |
519 | 518 | ||
520 | return &conn->dev; | 519 | return &conn->hcon->dev; |
521 | } | 520 | } |
522 | 521 | ||
523 | static struct device_type bnep_type = { | 522 | static struct device_type bnep_type = { |