diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-10-11 16:59:40 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-10-11 17:00:08 +0200 |
commit | 8ed5d192c0beb34c9a679b390c2e4077ae977dc2 (patch) | |
tree | 4719ad90a3a5fd8c47fd108aae9dff61e3ddb904 /sound/usb/line6 | |
parent | 19b592dae895aad10b84246b0e12caad04e9eb0d (diff) | |
parent | 4f95646c803f6a534e58b1d33afbfdaf3e122328 (diff) | |
download | linux-8ed5d192c0beb34c9a679b390c2e4077ae977dc2.tar.gz linux-8ed5d192c0beb34c9a679b390c2e4077ae977dc2.tar.bz2 linux-8ed5d192c0beb34c9a679b390c2e4077ae977dc2.zip |
Merge branch 'topic/usb-ep-check-v2' into for-next
Pulling the EP validity checks in USB audio drivers.
It also adds a new helper in USB core, which was acked by Greg.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/line6')
-rw-r--r-- | sound/usb/line6/driver.c | 30 | ||||
-rw-r--r-- | sound/usb/line6/midi.c | 17 |
2 files changed, 33 insertions, 14 deletions
diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 0ff5a7d2e19f..7c682b219584 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -78,6 +78,13 @@ static int line6_start_listen(struct usb_line6 *line6) line6->buffer_listen, LINE6_BUFSIZE_LISTEN, line6_data_received, line6); } + + /* sanity checks of EP before actually submitting */ + if (usb_urb_ep_type_check(line6->urb_listen)) { + dev_err(line6->ifcdev, "invalid control EP\n"); + return -EINVAL; + } + line6->urb_listen->actual_length = 0; err = usb_submit_urb(line6->urb_listen, GFP_ATOMIC); return err; @@ -168,17 +175,24 @@ static int line6_send_raw_message_async_part(struct message *msg, } msg->done += bytes; - retval = usb_submit_urb(urb, GFP_ATOMIC); - if (retval < 0) { - dev_err(line6->ifcdev, "%s: usb_submit_urb failed (%d)\n", - __func__, retval); - usb_free_urb(urb); - kfree(msg); - return retval; - } + /* sanity checks of EP before actually submitting */ + retval = usb_urb_ep_type_check(urb); + if (retval < 0) + goto error; + + retval = usb_submit_urb(urb, GFP_ATOMIC); + if (retval < 0) + goto error; return 0; + + error: + dev_err(line6->ifcdev, "%s: usb_submit_urb failed (%d)\n", + __func__, retval); + usb_free_urb(urb); + kfree(msg); + return retval; } /* diff --git a/sound/usb/line6/midi.c b/sound/usb/line6/midi.c index 1d3a23b02d68..6d7cde56a355 100644 --- a/sound/usb/line6/midi.c +++ b/sound/usb/line6/midi.c @@ -130,16 +130,21 @@ static int send_midi_async(struct usb_line6 *line6, unsigned char *data, transfer_buffer, length, midi_sent, line6, line6->interval); urb->actual_length = 0; - retval = usb_submit_urb(urb, GFP_ATOMIC); + retval = usb_urb_ep_type_check(urb); + if (retval < 0) + goto error; - if (retval < 0) { - dev_err(line6->ifcdev, "usb_submit_urb failed\n"); - usb_free_urb(urb); - return retval; - } + retval = usb_submit_urb(urb, GFP_ATOMIC); + if (retval < 0) + goto error; ++line6->line6midi->num_active_send_urbs; return 0; + + error: + dev_err(line6->ifcdev, "usb_submit_urb failed\n"); + usb_free_urb(urb); + return retval; } static int line6_midi_output_open(struct snd_rawmidi_substream *substream) |