Re: [patch v2] ALSA: rawmidi: fix the get next midi device ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 8 Sep 2010, Takashi Iwai wrote:

> At Wed, 8 Sep 2010 21:36:41 +0200,
> Dan Carpenter wrote:
>>
>> If we pass in a device which is higher than SNDRV_RAWMIDI_DEVICES then
>> this function just returns device + 1 which isn't helpful.  I've
>> modified it to return -EINVAL instead.
>>
>> Also Smatch complains because the "device + 1" could be an integer
>> overflow.  It's harmless, but we may as well silence the warning.
>>
>> Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
>> ---
>> V2:  In the first version I made negative values return -EINVAL
>>
>> diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
>> index eb68326..1633bac 100644
>> --- a/sound/core/rawmidi.c
>> +++ b/sound/core/rawmidi.c
>> @@ -829,6 +829,8 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card,
>>
>>  		if (get_user(device, (int __user *)argp))
>>  			return -EFAULT;
>> +		if (device > SNDRV_RAWMIDI_DEVICES)
>> +			return -EINVAL;
>
> This should be "device >= SNDRV_RAWMIDI_DEVICES".

Also note that this check changes a bit semantics. All other NEXT_DEVICE 
ioctls returns -1 if the value is beyond the last device (meaning no more 
devices were found). So the

                if (device == SNDRV_RAWMIDI_DEVICES)
                         device = -1;

check should be

                if (device >= SNDRV_RAWMIDI_DEVICES)
                         device = -1;

... resulting in one line patch.

 					Jaroslav


-----
Jaroslav Kysela <perex@xxxxxxxx>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel


[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux