projects/linux·commit c19483cc

bluetooth: Fix missing NULL check

c19483cc · Alan Cox <[email protected]> · 2010-10-22 14:11:26 +01:00

Fortunately this is only exploitable on very unusual hardware.

[Reported a while ago but nothing happened so just fixing it]

Signed-off-by: Alan Cox <[email protected]>
Cc: [email protected]
Signed-off-by: Linus Torvalds <[email protected]>
Commit
c19483cc5e56ac5e22dd19cf25ba210ab1537773
Parents
d4429f60

Changes

1 files changed · +7 −0

FileStatusAddDelContent
drivers/bluetooth/hci_ldisc.cmodified+7−0View file

drivers/bluetooth/hci_ldisc.c

View file
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 998833d..17361ba 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -256,9 +256,16 @@ static int hci_uart_tty_open(struct tty_struct *tty)
BT_DBG("tty %p", tty);
+ /* FIXME: This btw is bogus, nothing requires the old ldisc to clear
+ the pointer */
if (hu)
return -EEXIST;
+ /* Error if the tty has no write op instead of leaving an exploitable
+ hole */
+ if (tty->ops->write == NULL)
+ return -EOPNOTSUPP;
+
if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) {
BT_ERR("Can't allocate control structure");
return -ENFILE;