Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 797fe796 authored by David Herrmann's avatar David Herrmann Committed by Johan Hedberg
Browse files

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: default avatarDavid Herrmann <dh.herrmann@googlemail.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent dabbaab3
Loading
Loading
Loading
Loading
+2 −10
Original line number Original line Diff line number Diff line
@@ -231,15 +231,6 @@ static int hci_uart_send_frame(struct sk_buff *skb)
	return 0;
	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 ------ */
/* ------ LDISC part ------ */
/* hci_uart_tty_open
/* hci_uart_tty_open
 * 
 * 
@@ -316,6 +307,8 @@ static void hci_uart_tty_close(struct tty_struct *tty)
				hci_free_dev(hdev);
				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->close = hci_uart_close;
	hdev->flush = hci_uart_flush;
	hdev->flush = hci_uart_flush;
	hdev->send  = hci_uart_send_frame;
	hdev->send  = hci_uart_send_frame;
	hdev->destruct = hci_uart_destruct;
	hdev->parent = hu->tty->dev;
	hdev->parent = hu->tty->dev;


	hdev->owner = THIS_MODULE;
	hdev->owner = THIS_MODULE;