From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>,
Yacine Belkadi <yacine.belkadi.1@gmail.com>,
alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: [patch] ALSA: bits vs bytes bug in snd_card_create()
Date: Thu, 23 Jan 2014 11:21:28 +0300 [thread overview]
Message-ID: <20140123082128.GA28688@elgon.mountain> (raw)
The test here is intended intended to prevent shift wrapping bugs when
we do "1U << idx2". We should consider the number of bits in a u32
instead of the number of bytes.
Fixes: 7bb2491b35a2 ('ALSA: Add kconfig to specify the max card numbers')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
WARNING: Please check this one carefully because I might be wrong.
diff --git a/sound/core/init.c b/sound/core/init.c
index 1351f22f651c..e9e3db321e64 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -183,7 +183,7 @@ int snd_card_create(int idx, const char *xid,
if (idx < 0) {
for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) {
/* idx == -1 == 0xffff means: take any free slot */
- if (idx2 < sizeof(int) && !(idx & (1U << idx2)))
+ if (idx2 < 32 && !(idx & (1U << idx2)))
continue;
if (!test_bit(idx2, snd_cards_lock)) {
if (!slots[idx2] || !*slots[idx2]) {
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>,
Yacine Belkadi <yacine.belkadi.1@gmail.com>,
alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: [patch] ALSA: bits vs bytes bug in snd_card_create()
Date: Thu, 23 Jan 2014 08:21:28 +0000 [thread overview]
Message-ID: <20140123082128.GA28688@elgon.mountain> (raw)
The test here is intended intended to prevent shift wrapping bugs when
we do "1U << idx2". We should consider the number of bits in a u32
instead of the number of bytes.
Fixes: 7bb2491b35a2 ('ALSA: Add kconfig to specify the max card numbers')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
WARNING: Please check this one carefully because I might be wrong.
diff --git a/sound/core/init.c b/sound/core/init.c
index 1351f22f651c..e9e3db321e64 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -183,7 +183,7 @@ int snd_card_create(int idx, const char *xid,
if (idx < 0) {
for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) {
/* idx = -1 = 0xffff means: take any free slot */
- if (idx2 < sizeof(int) && !(idx & (1U << idx2)))
+ if (idx2 < 32 && !(idx & (1U << idx2)))
continue;
if (!test_bit(idx2, snd_cards_lock)) {
if (!slots[idx2] || !*slots[idx2]) {
next reply other threads:[~2014-01-23 8:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-23 8:21 Dan Carpenter [this message]
2014-01-23 8:21 ` [patch] ALSA: bits vs bytes bug in snd_card_create() Dan Carpenter
2014-01-23 8:36 ` Takashi Iwai
2014-01-23 8:36 ` Takashi Iwai
2014-01-23 10:48 ` Takashi Iwai
2014-01-23 10:48 ` Takashi Iwai
2014-01-23 8:55 ` walter harms
2014-01-23 8:55 ` walter harms
2014-01-23 9:02 ` Takashi Iwai
2014-01-23 9:02 ` Takashi Iwai
2014-01-23 9:27 ` walter harms
2014-01-23 9:27 ` walter harms
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=20140123082128.GA28688@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=alsa-devel@alsa-project.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
--cc=yacine.belkadi.1@gmail.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.