summaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2011-10-28 09:46:01 +0300
committerTakashi Iwai <tiwai@suse.de>2011-10-31 09:52:43 +0100
commitf7b2bb8549e352353427d0f8913c96914dd0baab (patch)
tree33f5ae7bb40d02c9a552115a0dd587029f2e32f6 /sound/core
parent8128c9f21509f9a8b6da94ac432d845dda458406 (diff)
downloadlinux-f7b2bb8549e352353427d0f8913c96914dd0baab.tar.gz
linux-f7b2bb8549e352353427d0f8913c96914dd0baab.tar.bz2
linux-f7b2bb8549e352353427d0f8913c96914dd0baab.zip
ALSA: hwdep: silence integer overflow warning
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>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/hwdep.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index a70ee7f1ed98..031e215b6dde 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -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;