From: Takashi Iwai <tiwai@suse.de>
To: Jaroslav Kysela <perex@perex.cz>
Cc: ALSA development <alsa-devel@alsa-project.org>,
Dan Carpenter <error27@gmail.com>,
Clemens Ladisch <clemens@ladisch.de>,
kernel-janitors@vger.kernel.org, Kyle McMartin <kyle@mcmartin.ca>,
Ulrich Drepper <drepper@redhat.com>
Subject: Re: [patch v2] ALSA: rawmidi: fix the get next midi device ioctl
Date: Thu, 09 Sep 2010 06:57:26 +0000 [thread overview]
Message-ID: <s5hk4mvs8tl.wl%tiwai@suse.de> (raw)
In-Reply-To: <alpine.LNX.2.00.1009082325570.6226@eeebox2.perex-int.cz>
At Wed, 8 Sep 2010 23:29:14 +0200 (CEST),
Jaroslav Kysela wrote:
>
> 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@gmail.com>
> >> ---
> >> 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.
But this doesn't work when you pass device = INT_MAX :)
Takashi
WARNING: multiple messages have this Message-ID (diff)
From: Takashi Iwai <tiwai@suse.de>
To: Jaroslav Kysela <perex@perex.cz>
Cc: ALSA development <alsa-devel@alsa-project.org>,
Dan Carpenter <error27@gmail.com>,
Clemens Ladisch <clemens@ladisch.de>,
kernel-janitors@vger.kernel.org, Kyle McMartin <kyle@mcmartin.ca>,
Ulrich Drepper <drepper@redhat.com>
Subject: Re: [patch v2] ALSA: rawmidi: fix the get next midi device ioctl
Date: Thu, 09 Sep 2010 08:57:26 +0200 [thread overview]
Message-ID: <s5hk4mvs8tl.wl%tiwai@suse.de> (raw)
In-Reply-To: <alpine.LNX.2.00.1009082325570.6226@eeebox2.perex-int.cz>
At Wed, 8 Sep 2010 23:29:14 +0200 (CEST),
Jaroslav Kysela wrote:
>
> 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@gmail.com>
> >> ---
> >> 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.
But this doesn't work when you pass device = INT_MAX :)
Takashi
next prev parent reply other threads:[~2010-09-09 6:57 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-08 8:53 [patch] ALSA: rawmidi: cleanup the get next midi device ioctl Dan Carpenter
2010-09-08 8:53 ` Dan Carpenter
2010-09-08 9:40 ` Clemens Ladisch
2010-09-08 9:40 ` Clemens Ladisch
2010-09-08 19:36 ` [patch v2] ALSA: rawmidi: fix " Dan Carpenter
2010-09-08 19:36 ` Dan Carpenter
2010-09-08 19:56 ` Takashi Iwai
2010-09-08 19:56 ` Takashi Iwai
2010-09-08 21:29 ` Jaroslav Kysela
2010-09-08 21:29 ` Jaroslav Kysela
2010-09-08 22:11 ` [patch v3] " Dan Carpenter
2010-09-08 22:11 ` Dan Carpenter
2010-09-09 7:07 ` Takashi Iwai
2010-09-09 7:07 ` Takashi Iwai
2010-09-09 8:36 ` Jaroslav Kysela
2010-09-09 8:36 ` Jaroslav Kysela
2010-09-09 7:23 ` walter harms
2010-09-09 7:23 ` walter harms
2010-09-09 6:57 ` Takashi Iwai [this message]
2010-09-09 6:57 ` [patch v2] " Takashi Iwai
2010-09-09 7:44 ` Clemens Ladisch
2010-09-09 7:44 ` Clemens Ladisch
2010-09-09 8:46 ` Dan Carpenter
2010-09-09 8:46 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5hk4mvs8tl.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--cc=drepper@redhat.com \
--cc=error27@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kyle@mcmartin.ca \
--cc=perex@perex.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.