aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2012-01-07 09:47:19 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-13 10:01:24 -0500
commit797fe796c4335b35d95d5326824513befdb5d1e9 (patch)
treec711b5d30e412dce8427e392c9379b6c03dce5fc /drivers/bluetooth
parentdabbaab394d17ba1d1b55092d553e6e31a3d0afd (diff)
Bluetooth: uart-ldisc: Fix memory leak and remove destruct cb
We currently leak the hci_uart object if HCI_UART_PROTO_SET is never set because the hci-destruct callback will then never be called. This fix removes the hci-destruct callback and frees the driver internal private hci_uart object directly on tty-close. We call hci_unregister_dev() here so the hci-core will never call our callbacks again (except destruct). Therefore, we can safely free the driver internal data right away and set the destruct callback to NULL. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/hci_ldisc.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 48ad2a7ab08..5ea49df3462 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -231,15 +231,6 @@ static int hci_uart_send_frame(struct sk_buff *skb)
231 return 0; 231 return 0;
232} 232}
233 233
234static void hci_uart_destruct(struct hci_dev *hdev)
235{
236 if (!hdev)
237 return;
238
239 BT_DBG("%s", hdev->name);
240 kfree(hdev->driver_data);
241}
242
243/* ------ LDISC part ------ */ 234/* ------ LDISC part ------ */
244/* hci_uart_tty_open 235/* hci_uart_tty_open
245 * 236 *
@@ -316,6 +307,8 @@ static void hci_uart_tty_close(struct tty_struct *tty)
316 hci_free_dev(hdev); 307 hci_free_dev(hdev);
317 } 308 }
318 } 309 }
310
311 kfree(hu);
319 } 312 }
320} 313}
321 314
@@ -397,7 +390,6 @@ static int hci_uart_register_dev(struct hci_uart *hu)
397 hdev->close = hci_uart_close; 390 hdev->close = hci_uart_close;
398 hdev->flush = hci_uart_flush; 391 hdev->flush = hci_uart_flush;
399 hdev->send = hci_uart_send_frame; 392 hdev->send = hci_uart_send_frame;
400 hdev->destruct = hci_uart_destruct;
401 hdev->parent = hu->tty->dev; 393 hdev->parent = hu->tty->dev;
402 394
403 hdev->owner = THIS_MODULE; 395 hdev->owner = THIS_MODULE;