From: Johan Hovold Date: Wed, 11 Apr 2012 09:24:35 +0000 (+0200) Subject: Bluetooth: uart-ldisc: Fix memory leak X-Git-Tag: v3.0.29~56 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b8162209f9bfd832fc854cf12779d612df661ee6;p=karo-tx-linux.git Bluetooth: uart-ldisc: Fix memory leak This is a partial, self-contained, minimal backport of commit 797fe796c4335b35d95d5326824513befdb5d1e9 upstream which fixes the memory leak: 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 Acked-by: Marcel Holtmann Signed-off-by: Johan Hedberg Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 48ad2a7ab080..36dafef7ca81 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -237,7 +237,6 @@ static void hci_uart_destruct(struct hci_dev *hdev) return; BT_DBG("%s", hdev->name); - kfree(hdev->driver_data); } /* ------ LDISC part ------ */ @@ -316,6 +315,7 @@ static void hci_uart_tty_close(struct tty_struct *tty) hci_free_dev(hdev); } } + kfree(hu); } }