public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] [ALSA] hwdep: silence integer overflow warning
@ 2011-10-20  6:09 Dan Carpenter
  2011-10-20  7:39 ` walter harms
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2011-10-20  6:09 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, Paul Gortmaker, alsa-devel, kernel-janitors

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>

diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index c7ceb28..edfdf6d 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -273,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 = SNDRV_MINOR_HWDEPS;
+			else
+				device++;
+
 			while (device < SNDRV_MINOR_HWDEPS) {
 				if (snd_hwdep_search(card, device))
 					break;

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-10-31  8:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-20  6:09 [patch] [ALSA] hwdep: silence integer overflow warning Dan Carpenter
2011-10-20  7:39 ` walter harms
2011-10-28  6:45   ` Dan Carpenter
2011-10-28  7:33     ` walter harms
2011-10-28  8:55       ` Dan Carpenter
2011-10-28  6:46   ` [patch v2] " Dan Carpenter
2011-10-31  8:55     ` [alsa-devel] " Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox