Skip to content

Commit

Permalink
ALSA: hwdep: silence integer overflow warning
Browse files Browse the repository at this point in the history
Smatch complains that if device is INT_MAX then device + 1 can
overflow.  It just means we would have an annoying loop while we
check all the devices from -2147483648 to SNDRV_MINOR_HWDEPS.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Dan Carpenter authored and Takashi Iwai committed Oct 31, 2011
1 parent 8128c9f commit f7b2bb8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sound/core/hwdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,14 @@ static int snd_hwdep_control_ioctl(struct snd_card *card,
if (get_user(device, (int __user *)arg))
return -EFAULT;
mutex_lock(&register_mutex);
device = device < 0 ? 0 : device + 1;

if (device < 0)
device = 0;
else if (device < SNDRV_MINOR_HWDEPS)
device++;
else
device = SNDRV_MINOR_HWDEPS;

while (device < SNDRV_MINOR_HWDEPS) {
if (snd_hwdep_search(card, device))
break;
Expand Down

0 comments on commit f7b2bb8

Please sign in to comment.