USB: gadget: midi: fix range check in
Subsystems (2)
PATCH 1/2 USB: gadget: midi: fix range check in
! has higher precedence than >= and since neither 0 nor 1 are greater than 8 the condition is always false.
Signed-off-by Dan Carpenter <[email protected]>
drivers/usb/gadget/f_midi.c +1 -1
@@ -644,7 +644,7 @@ static int f_midi_out_open(struct snd_rawmidi_substream *substream) {struct f_midi *midi = substream->rmidi->private_data; -if (!substream->number >=MAX_PORTS ) +if (substream->number >=MAX_PORTS )return -EINVAL ;VDBG (midi,"%s()\n" , __func__);
Re: [patch 1/2 -next] USB: gadget: midi: fix range check in f_midi_out_open()
Quoted 2 lines · Dan Carpenter
! has higher precedence than>= and since neither 0 nor 1 are greater than 8 the condition is always false.
Sure. The call in question actually not more than a sanity check, as lower layers will never call this function with an invalid substream number.
Thanks for spotting this.
Quoted 1 line
Signed-off-by Dan Carpenter<[email protected]>
Acked-by Daniel Mack <[email protected]>
Quoted 14 lines
drivers/usb/gadget/f_midi.c +1
-1@@ -644,7 +644,7 @@ static int f_midi_out_open(struct snd_rawmidi_substream *substream) {struct f_midi *midi = substream->rmidi->private_data; -if (!substream->number>=MAX_PORTS ) +if (substream->number>=MAX_PORTS )return -EINVAL ;VDBG (midi,"%s()\n" , __func__);