linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Fix memory leak in hci_connect_le_scan
@ 2019-11-21 20:20 Navid Emamdoost
  2019-11-22  9:43 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2019-11-21 20:20 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, David S. Miller, linux-bluetooth,
	netdev, linux-kernel
  Cc: emamd001, Navid Emamdoost

In the implementation of hci_connect_le_scan() when conn is added via
hci_conn_add(), if hci_explicit_conn_params_set() fails the allocated
memory for conn is leaked. Use hci_conn_del() to release it.

Fixes: f75113a26008 ("Bluetooth: add hci_connect_le_scan")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 net/bluetooth/hci_conn.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index ad5b0ac1f9ce..4472ec02c3e2 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1168,8 +1168,10 @@ struct hci_conn *hci_connect_le_scan(struct hci_dev *hdev, bdaddr_t *dst,
 	if (!conn)
 		return ERR_PTR(-ENOMEM);
 
-	if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0)
+	if (hci_explicit_conn_params_set(hdev, dst, dst_type) < 0) {
+		hci_conn_del(conn);
 		return ERR_PTR(-EBUSY);
+	}
 
 	conn->state = BT_CONNECT;
 	set_bit(HCI_CONN_SCANNING, &conn->flags);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Bluetooth: Fix memory leak in hci_connect_le_scan
  2019-11-21 20:20 [PATCH] Bluetooth: Fix memory leak in hci_connect_le_scan Navid Emamdoost
@ 2019-11-22  9:43 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2019-11-22  9:43 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: Johan Hedberg, David S. Miller, linux-bluetooth, netdev,
	linux-kernel, emamd001

Hi Navid,

> In the implementation of hci_connect_le_scan() when conn is added via
> hci_conn_add(), if hci_explicit_conn_params_set() fails the allocated
> memory for conn is leaked. Use hci_conn_del() to release it.
> 
> Fixes: f75113a26008 ("Bluetooth: add hci_connect_le_scan")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> net/bluetooth/hci_conn.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-22  9:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-21 20:20 [PATCH] Bluetooth: Fix memory leak in hci_connect_le_scan Navid Emamdoost
2019-11-22  9:43 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).