diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/mgmt.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 42d665bdc01..7fdba8fb980 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1725,8 +1725,8 @@ static int get_connections(struct sock *sk, u16 index) | |||
1725 | struct hci_dev *hdev; | 1725 | struct hci_dev *hdev; |
1726 | struct hci_conn *c; | 1726 | struct hci_conn *c; |
1727 | size_t rp_len; | 1727 | size_t rp_len; |
1728 | u16 count; | 1728 | int err; |
1729 | int i, err; | 1729 | u16 i; |
1730 | 1730 | ||
1731 | BT_DBG(""); | 1731 | BT_DBG(""); |
1732 | 1732 | ||
@@ -1743,21 +1743,19 @@ static int get_connections(struct sock *sk, u16 index) | |||
1743 | goto unlock; | 1743 | goto unlock; |
1744 | } | 1744 | } |
1745 | 1745 | ||
1746 | count = 0; | 1746 | i = 0; |
1747 | list_for_each_entry(c, &hdev->conn_hash.list, list) { | 1747 | list_for_each_entry(c, &hdev->conn_hash.list, list) { |
1748 | if (test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) | 1748 | if (test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) |
1749 | count++; | 1749 | i++; |
1750 | } | 1750 | } |
1751 | 1751 | ||
1752 | rp_len = sizeof(*rp) + (count * sizeof(struct mgmt_addr_info)); | 1752 | rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); |
1753 | rp = kmalloc(rp_len, GFP_ATOMIC); | 1753 | rp = kmalloc(rp_len, GFP_ATOMIC); |
1754 | if (!rp) { | 1754 | if (!rp) { |
1755 | err = -ENOMEM; | 1755 | err = -ENOMEM; |
1756 | goto unlock; | 1756 | goto unlock; |
1757 | } | 1757 | } |
1758 | 1758 | ||
1759 | put_unaligned_le16(count, &rp->conn_count); | ||
1760 | |||
1761 | i = 0; | 1759 | i = 0; |
1762 | list_for_each_entry(c, &hdev->conn_hash.list, list) { | 1760 | list_for_each_entry(c, &hdev->conn_hash.list, list) { |
1763 | if (!test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) | 1761 | if (!test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) |
@@ -1769,6 +1767,8 @@ static int get_connections(struct sock *sk, u16 index) | |||
1769 | i++; | 1767 | i++; |
1770 | } | 1768 | } |
1771 | 1769 | ||
1770 | put_unaligned_le16(i, &rp->conn_count); | ||
1771 | |||
1772 | /* Recalculate length in case of filtered SCO connections, etc */ | 1772 | /* Recalculate length in case of filtered SCO connections, etc */ |
1773 | rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); | 1773 | rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); |
1774 | 1774 | ||