Merge branch 'for-usb-linus' of git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci...
[pandora-kernel.git] / sound / core / hwdep.c
index a70ee7f..75ea16f 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/mutex.h>
+#include <linux/module.h>
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/minors.h>
@@ -272,7 +273,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;