Skip to contentSkip to conversation

USB: gadget: midi: fix range check in

PATCH In review Dan Carpenter 2 participants 2 messages Oct 18, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

drivers/usb/gadget/f_midi.c +1 -1
index 44858dc..ef1bc7a 100644
@@ -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__);
Acked-by on v1 1/2
#1 lore raw

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
Quoted 14 lines
drivers/usb/gadget/f_midi.c +1 -1
index 44858dc..ef1bc7a 100644
@@ -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__);