]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ALSA: hda - Return the error from get_wcaps_type() for invalid NIDs
authorTakashi Iwai <tiwai@suse.de>
Tue, 10 Jan 2012 11:41:22 +0000 (12:41 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 25 Jan 2012 21:53:18 +0000 (13:53 -0800)
commit 3a90274de3548ebb2aabfbf488cea8e275a73dc6 upstream.

When an invalid NID is given, get_wcaps() returns zero as the error,
but get_wcaps_type() takes it as the normal value and returns a bogus
AC_WID_AUD_OUT value.  This confuses the parser.

With this patch, get_wcaps_type() returns -1 when value 0 is given,
i.e. an invalid NID is passed to get_wcaps().

Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=740118

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
sound/pci/hda/hda_local.h
sound/pci/hda/hda_proc.c

index 5f1dcc59002b4a610f0bff8b6455e9d1205f42a9..f8ac43aa0eb7a9200b78d737f4d0832fee75b1fd 100644 (file)
@@ -408,7 +408,12 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
 }
 
 /* get the widget type from widget capability bits */
-#define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT)
+static inline int get_wcaps_type(unsigned int wcaps)
+{
+       if (!wcaps)
+               return -1; /* invalid type */
+       return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
+}
 
 static inline unsigned int get_wcaps_channels(u32 wcaps)
 {
index 95f24e4729f83c5eede0328f26bef18f2021a68c..2b3d859401a28def5d90477f89b72158bc94f837 100644 (file)
@@ -39,6 +39,8 @@ static const char *get_wid_type_name(unsigned int wid_value)
                [AC_WID_BEEP] = "Beep Generator Widget",
                [AC_WID_VENDOR] = "Vendor Defined Widget",
        };
+       if (wid_value == -1)
+               return "UNKNOWN Widget";
        wid_value &= 0xf;
        if (names[wid_value])
                return names[wid_value];