Merge tag 'sound-4.15-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / sound / usb / bcd2000 / bcd2000.c
index 7371e5b0603564e37190d074b5ae9506c80c3e32..d6c8b29fe430b659a7079566eeea91e76f48cc9f 100644 (file)
@@ -108,7 +108,7 @@ static void bcd2000_midi_handle_input(struct bcd2000 *bcd2k,
        unsigned int payload_length, tocopy;
        struct snd_rawmidi_substream *midi_receive_substream;
 
-       midi_receive_substream = ACCESS_ONCE(bcd2k->midi_receive_substream);
+       midi_receive_substream = READ_ONCE(bcd2k->midi_receive_substream);
        if (!midi_receive_substream)
                return;
 
@@ -139,7 +139,7 @@ static void bcd2000_midi_send(struct bcd2000 *bcd2k)
 
        BUILD_BUG_ON(sizeof(device_cmd_prefix) >= BUFSIZE);
 
-       midi_out_substream = ACCESS_ONCE(bcd2k->midi_out_substream);
+       midi_out_substream = READ_ONCE(bcd2k->midi_out_substream);
        if (!midi_out_substream)
                return;
 
@@ -342,6 +342,13 @@ static int bcd2000_init_midi(struct bcd2000 *bcd2k)
                                bcd2k->midi_out_buf, BUFSIZE,
                                bcd2000_output_complete, bcd2k, 1);
 
+       /* sanity checks of EPs before actually submitting */
+       if (usb_urb_ep_type_check(bcd2k->midi_in_urb) ||
+           usb_urb_ep_type_check(bcd2k->midi_out_urb)) {
+               dev_err(&bcd2k->dev->dev, "invalid MIDI EP\n");
+               return -EINVAL;
+       }
+
        bcd2000_init_device(bcd2k);
 
        return 0;