aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-07-11 01:12:57 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2014-07-11 06:59:47 -0400
commitbb72bd68fd87a4347b2a891ab16aac6014e69a00 (patch)
treecd1ac7deca0eb2740da3ce811f9326820f78d22a
parent068d69e5bbd85291aa8ad0d81062f047609a173c (diff)
Bluetooth: Check for valid HCI UART driver flags
Providing unknown or invalid flags to the HCI UART driver should result in an error. So check which flags are valid and otherwise return an error. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--drivers/bluetooth/hci_ldisc.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index e00f8f5b5c8e..a49ee1b42439 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -477,6 +477,21 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id)
477 return 0; 477 return 0;
478} 478}
479 479
480static int hci_uart_set_flags(struct hci_uart *hu, unsigned long flags)
481{
482 unsigned long valid_flags = BIT(HCI_UART_RAW_DEVICE) |
483 BIT(HCI_UART_RESET_ON_INIT) |
484 BIT(HCI_UART_CREATE_AMP) |
485 BIT(HCI_UART_INIT_PENDING);
486
487 if ((flags & ~valid_flags))
488 return -EINVAL;
489
490 hu->hdev_flags = flags;
491
492 return 0;
493}
494
480/* hci_uart_tty_ioctl() 495/* hci_uart_tty_ioctl()
481 * 496 *
482 * Process IOCTL system call for the tty device. 497 * Process IOCTL system call for the tty device.
@@ -527,7 +542,9 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
527 case HCIUARTSETFLAGS: 542 case HCIUARTSETFLAGS:
528 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) 543 if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
529 return -EBUSY; 544 return -EBUSY;
530 hu->hdev_flags = arg; 545 err = hci_uart_set_flags(hu, arg);
546 if (err)
547 return err;
531 break; 548 break;
532 549
533 case HCIUARTGETFLAGS: 550 case HCIUARTGETFLAGS: