All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org,
	Takashi Sakamoto <o-takashi@sakamocchi.jp>,
	kernel-janitors@vger.kernel.org, Takashi Iwai <tiwai@suse.com>
Subject: [PATCH] ALSA: dice: fix a bounds check in snd_dice_detect_tcelectronic_formats()
Date: Fri, 18 May 2018 12:16:07 +0300	[thread overview]
Message-ID: <20180518091607.GA32078@mwanda> (raw)

The "entry" pointer is always non-NULL so this test for out of bounds
won't work.

Fixes: f1f0f330b1d0 ("ALSA: dice: add parameters of stream formats for models produced by TC Electronic")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/sound/firewire/dice/dice-tcelectronic.c b/sound/firewire/dice/dice-tcelectronic.c
index af8203b9d1a6..e134a5110c6c 100644
--- a/sound/firewire/dice/dice-tcelectronic.c
+++ b/sound/firewire/dice/dice-tcelectronic.c
@@ -75,13 +75,12 @@ int snd_dice_detect_tcelectronic_formats(struct snd_dice *dice)
 		}
 	}
 
-	entry = NULL;
 	for (i = 0; i < ARRAY_SIZE(entries); ++i) {
 		entry = entries + i;
 		if (entry->model_id == model_id)
 			break;
 	}
-	if (!entry)
+	if (i == ARRAY_SIZE(entries))
 		return -ENODEV;
 
 	memcpy(dice->tx_pcm_chs, entry->spec->tx_pcm_chs,

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org,
	Takashi Sakamoto <o-takashi@sakamocchi.jp>,
	kernel-janitors@vger.kernel.org, Takashi Iwai <tiwai@suse.com>
Subject: [PATCH] ALSA: dice: fix a bounds check in snd_dice_detect_tcelectronic_formats()
Date: Fri, 18 May 2018 09:16:07 +0000	[thread overview]
Message-ID: <20180518091607.GA32078@mwanda> (raw)

The "entry" pointer is always non-NULL so this test for out of bounds
won't work.

Fixes: f1f0f330b1d0 ("ALSA: dice: add parameters of stream formats for models produced by TC Electronic")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/sound/firewire/dice/dice-tcelectronic.c b/sound/firewire/dice/dice-tcelectronic.c
index af8203b9d1a6..e134a5110c6c 100644
--- a/sound/firewire/dice/dice-tcelectronic.c
+++ b/sound/firewire/dice/dice-tcelectronic.c
@@ -75,13 +75,12 @@ int snd_dice_detect_tcelectronic_formats(struct snd_dice *dice)
 		}
 	}
 
-	entry = NULL;
 	for (i = 0; i < ARRAY_SIZE(entries); ++i) {
 		entry = entries + i;
 		if (entry->model_id = model_id)
 			break;
 	}
-	if (!entry)
+	if (i = ARRAY_SIZE(entries))
 		return -ENODEV;
 
 	memcpy(dice->tx_pcm_chs, entry->spec->tx_pcm_chs,

             reply	other threads:[~2018-05-18  9:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-18  9:16 Dan Carpenter [this message]
2018-05-18  9:16 ` [PATCH] ALSA: dice: fix a bounds check in snd_dice_detect_tcelectronic_formats() Dan Carpenter
2018-05-18 11:36 ` Takashi Sakamoto
2018-05-18 11:36   ` Takashi Sakamoto
2018-05-18 11:39 ` Takashi Iwai
2018-05-18 11:39   ` Takashi Iwai

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=20180518091607.GA32078@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=o-takashi@sakamocchi.jp \
    --cc=tiwai@suse.com \
    /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.