diff options
author | David Herrmann <dh.herrmann@googlemail.com> | 2011-10-26 05:22:46 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-11-07 14:24:54 -0500 |
commit | 7f103a0d23d2778b86cea407c1992522d41ead81 (patch) | |
tree | c8319c639e4bef02ab88bdf35ff080a3b3850040 /drivers/bluetooth | |
parent | deceb024f1083d7eecaba7f2ee65d57f31f91bd5 (diff) |
Bluetooth: bfusb: Fix error path on firmware load
When loading the usb-configuration we do not signal the end of configuration on
memory allocation error. This patch moves the memory allocation to the top so
every error path uses "goto error" now to correctly send the usb-ctrl message
when detecting some error.
This also replaces GFP_ATOMIC with GFP_KERNEL as we are allowed to sleep here.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/bfusb.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 6580d5057d26..a936763b8c3d 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c | |||
@@ -568,22 +568,23 @@ static int bfusb_load_firmware(struct bfusb_data *data, | |||
568 | 568 | ||
569 | BT_INFO("BlueFRITZ! USB loading firmware"); | 569 | BT_INFO("BlueFRITZ! USB loading firmware"); |
570 | 570 | ||
571 | buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_KERNEL); | ||
572 | if (!buf) { | ||
573 | BT_ERR("Can't allocate memory chunk for firmware"); | ||
574 | return -ENOMEM; | ||
575 | } | ||
576 | |||
571 | pipe = usb_sndctrlpipe(data->udev, 0); | 577 | pipe = usb_sndctrlpipe(data->udev, 0); |
572 | 578 | ||
573 | if (usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION, | 579 | if (usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION, |
574 | 0, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT) < 0) { | 580 | 0, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT) < 0) { |
575 | BT_ERR("Can't change to loading configuration"); | 581 | BT_ERR("Can't change to loading configuration"); |
582 | kfree(buf); | ||
576 | return -EBUSY; | 583 | return -EBUSY; |
577 | } | 584 | } |
578 | 585 | ||
579 | data->udev->toggle[0] = data->udev->toggle[1] = 0; | 586 | data->udev->toggle[0] = data->udev->toggle[1] = 0; |
580 | 587 | ||
581 | buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_ATOMIC); | ||
582 | if (!buf) { | ||
583 | BT_ERR("Can't allocate memory chunk for firmware"); | ||
584 | return -ENOMEM; | ||
585 | } | ||
586 | |||
587 | pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep); | 588 | pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep); |
588 | 589 | ||
589 | while (count) { | 590 | while (count) { |