From: David Herrmann <dh.herrmann@googlemail.com>
To: linux-bluetooth@vger.kernel.org
Cc: padovan@profusion.mobi, marcel@holtmann.org,
David Herrmann <dh.herrmann@googlemail.com>
Subject: [PATCH 13/18] Bluetooth: uart-ldisc: Fix memory leak and remove destruct cb
Date: Sat, 7 Jan 2012 15:47:19 +0100 [thread overview]
Message-ID: <1325947644-11736-14-git-send-email-dh.herrmann@googlemail.com> (raw)
In-Reply-To: <1325947644-11736-1-git-send-email-dh.herrmann@googlemail.com>
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>
---
drivers/bluetooth/hci_ldisc.c | 12 ++----------
1 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 48ad2a7..5ea49df 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)
return 0;
}
-static void hci_uart_destruct(struct hci_dev *hdev)
-{
- if (!hdev)
- return;
-
- BT_DBG("%s", hdev->name);
- kfree(hdev->driver_data);
-}
-
/* ------ LDISC part ------ */
/* hci_uart_tty_open
*
@@ -316,6 +307,8 @@ static void hci_uart_tty_close(struct tty_struct *tty)
hci_free_dev(hdev);
}
}
+
+ kfree(hu);
}
}
@@ -397,7 +390,6 @@ static int hci_uart_register_dev(struct hci_uart *hu)
hdev->close = hci_uart_close;
hdev->flush = hci_uart_flush;
hdev->send = hci_uart_send_frame;
- hdev->destruct = hci_uart_destruct;
hdev->parent = hu->tty->dev;
hdev->owner = THIS_MODULE;
--
1.7.8.1
next prev parent reply other threads:[~2012-01-07 14:47 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-07 14:47 [PATCH 00/18] Cleanup HCI reference counts David Herrmann
2012-01-07 14:47 ` [PATCH 01/18] Bluetooth: Make hci-destruct callback optional David Herrmann
2012-01-07 14:47 ` [PATCH 02/18] Bluetooth: bluecard-cs: Remove empty destruct cb David Herrmann
2012-01-07 14:47 ` [PATCH 03/18] Bluetooth: bt3c-cs: " David Herrmann
2012-01-07 14:47 ` [PATCH 04/18] Bluetooth: btmrvl: " David Herrmann
2012-01-07 14:47 ` [PATCH 05/18] Bluetooth: btuart-cs: " David Herrmann
2012-01-07 14:47 ` [PATCH 06/18] Bluetooth: btwilink: " David Herrmann
2012-01-07 14:47 ` [PATCH 07/18] Bluetooth: dtl1-cs: " David Herrmann
2012-01-07 14:47 ` [PATCH 08/18] Bluetooth: vhci: Free driver_data on file release David Herrmann
2012-01-07 14:47 ` [PATCH 09/18] Bluetooth: bfusb: Free driver_data on USB shutdown David Herrmann
2012-01-07 14:47 ` [PATCH 10/18] Bluetooth: btusb: Free driver data " David Herrmann
2012-01-07 14:47 ` [PATCH 11/18] Bluetooth: bpa10x: Free private driver data on usb shutdown David Herrmann
2012-01-07 14:47 ` [PATCH 12/18] Bluetooth: btsdio: Free driver data on SDIO shutdown David Herrmann
2012-01-07 14:47 ` David Herrmann [this message]
2012-01-07 14:47 ` [PATCH 14/18] Bluetooth: Remove unused hci-destruct cb David Herrmann
2012-01-07 14:47 ` [PATCH 15/18] Bluetooth: Correctly acquire module ref David Herrmann
2012-01-07 14:47 ` [PATCH 16/18] Bluetooth: Remove HCI-owner field David Herrmann
2012-01-07 14:47 ` [PATCH 17/18] Bluetooth: Correctly take hci_dev->dev refcount David Herrmann
2012-01-07 14:47 ` [PATCH 18/18] Bluetooth: Remove __hci_dev_put/hold David Herrmann
2012-01-09 7:54 ` [PATCH 00/18] Cleanup HCI reference counts Marcel Holtmann
2012-01-09 11:44 ` Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1325947644-11736-14-git-send-email-dh.herrmann@googlemail.com \
--to=dh.herrmann@googlemail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=padovan@profusion.mobi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).