From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Date: Wed, 08 Sep 2010 19:56:09 +0000 Subject: Re: [patch v2] ALSA: rawmidi: fix the get next midi device ioctl Message-Id: List-Id: References: <20100908085308.GC32047@bicker> <20100908193641.GA3463@bicker> In-Reply-To: <20100908193641.GA3463@bicker> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dan Carpenter Cc: alsa-devel@alsa-project.org, Clemens Ladisch , kernel-janitors@vger.kernel.org, Kyle McMartin , Ulrich Drepper 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 > --- > 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". Takashi > mutex_lock(®ister_mutex); > device = device < 0 ? 0 : device + 1; > while (device < SNDRV_RAWMIDI_DEVICES) { > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [patch v2] ALSA: rawmidi: fix the get next midi device ioctl Date: Wed, 08 Sep 2010 21:56:09 +0200 Message-ID: References: <20100908085308.GC32047@bicker> <20100908193641.GA3463@bicker> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (cantor.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id 11E9A103883 for ; Wed, 8 Sep 2010 21:56:10 +0200 (CEST) In-Reply-To: <20100908193641.GA3463@bicker> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Dan Carpenter Cc: alsa-devel@alsa-project.org, Clemens Ladisch , kernel-janitors@vger.kernel.org, Kyle McMartin , Ulrich Drepper List-Id: alsa-devel@alsa-project.org 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 > --- > 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". Takashi > mutex_lock(®ister_mutex); > device = device < 0 ? 0 : device + 1; > while (device < SNDRV_RAWMIDI_DEVICES) { >