lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <s5h8vqo8ry9.wl%tiwai@suse.de>
Date:	Sat, 20 Aug 2011 09:25:50 +0200
From:	Takashi Iwai <tiwai@...e.de>
To:	Tabi Timur-B04825 <B04825@...escale.com>
Cc:	Jesper Juhl <jj@...osbits.net>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"alsa-devel@...a-project.org" <alsa-devel@...a-project.org>,
	"Edgar (gimli) Hucek" <gimli@...k-green.com>,
	Tim Howe <tim.howe@...rus.com>,
	Stephen Warren <swarren@...dia.com>,
	Vince Weaver <vweaver1@...s.utk.edu>,
	Jaroslav Kysela <perex@...ex.cz>
Subject: Re: [PATCH] Sound, Cirrus: Remove redundant check

At Sat, 20 Aug 2011 00:16:57 +0000,
Tabi Timur-B04825 wrote:
> 
> On Fri, Aug 19, 2011 at 6:00 PM, Jesper Juhl <jj@...osbits.net> wrote:
> > The variable 'idxp' is a pointer to 'unsigned int', so the value
> > obtained when dereferencing it is always greater than or equal to
> > 0. Testing this is redundant.
> 
> snd_hda_get_conn_index() can return a negative number, so maybe *idxp
> should be a pointer to a signed int?

Yep, thanks for catching it.

I applied the patch below instead.


Takashi

---
From: Takashi Iwai <tiwai@...e.de>
Subject: [PATCH] ALSA: hda - Fix error check from snd_hda_get_conn_index() in
 patch_cirrus.c

snd_hda_get_conn_index() returns a negative value while the current code
stores it in an unsigned int.  It must be stored in a signed integer.

Reported-by: Jesper Juhl <jj@...osbits.net>
Signed-off-by: Takashi Iwai <tiwai@...e.de>
---
 sound/pci/hda/patch_cirrus.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 47d6ffc..d6c93d9 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -375,7 +375,7 @@ static int is_ext_mic(struct hda_codec *codec, unsigned int idx)
 static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin,
 			 unsigned int *idxp)
 {
-	int i;
+	int i, idx;
 	hda_nid_t nid;
 
 	nid = codec->start_nid;
@@ -384,9 +384,11 @@ static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin,
 		type = get_wcaps_type(get_wcaps(codec, nid));
 		if (type != AC_WID_AUD_IN)
 			continue;
-		*idxp = snd_hda_get_conn_index(codec, nid, pin, false);
-		if (*idxp >= 0)
+		idx = snd_hda_get_conn_index(codec, nid, pin, false);
+		if (idx >= 0) {
+			*idxp = idx;
 			return nid;
+		}
 	}
 	return 0;
 }
-- 
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ