The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda: Fix connection list comparison in proc output
@ 2026-08-18  8:38 raoxu
  2026-08-18  9:41 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-08-18  8:38 UTC (permalink / raw)
  To: perex; +Cc: tiwai, kees, cassiogabrielcontato, raoxu, linux-sound,
	linux-kernel

From: Xu Rao <raoxu@uniontech.com>

print_conn_list() compares the raw hardware connection list with the
connection list cached by the HDA driver.  When they differ, it prints an
additional "In-driver Connection" line so that /proc/asound/card*/codec#*
shows the topology actually used by the driver.

The comparison currently passes conn_len directly to memcmp().  However,
conn_len is a number of connection-list entries, while memcmp() expects a
size in bytes.  Both list and conn are arrays of hda_nid_t, which is u16,
so only half of the connection data is compared.

For example, for two-entry lists such as:

  hardware: 0x0c 0x0d
  cached:   0x0c 0x0e

conn_len is 2, and the current comparison checks only the first hda_nid_t.
The lists are therefore incorrectly treated as identical even though the
second connection differs.

This can happen legitimately when codec fixups replace a cached connection
list with snd_hda_override_conn_list().  The codec routing used by the
driver is not affected, but the proc output can hide the overridden
driver-visible routing and provide misleading topology information during
codec debugging.

Convert the entry count to a byte size so that memcmp() covers the
complete connection list.

Fixes: 8b2c7a5c404d ("ALSA: hda - Add In-driver connection info")
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
 sound/hda/common/proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/hda/common/proc.c b/sound/hda/common/proc.c
index c83796b13d3d..3dabdb418c7b 100644
--- a/sound/hda/common/proc.c
+++ b/sound/hda/common/proc.c
@@ -624,7 +624,7 @@ static void print_conn_list(struct snd_info_buffer *buffer,
 	/* Get Cache connections info */
 	cache_len = snd_hda_get_conn_list(codec, nid, &list);
 	if (cache_len >= 0 && (cache_len != conn_len ||
-			      memcmp(list, conn, conn_len) != 0)) {
+			      memcmp(list, conn, conn_len * sizeof(*conn)) != 0)) {
 		snd_iprintf(buffer, "  In-driver Connection: %d\n", cache_len);
 		if (cache_len > 0) {
 			snd_iprintf(buffer, "    ");
--
2.50.1


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

* Re: [PATCH] ALSA: hda: Fix connection list comparison in proc output
  2026-08-18  8:38 [PATCH] ALSA: hda: Fix connection list comparison in proc output raoxu
@ 2026-08-18  9:41 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-08-18  9:41 UTC (permalink / raw)
  To: raoxu; +Cc: perex, tiwai, kees, cassiogabrielcontato, linux-sound,
	linux-kernel

On Tue, 18 Aug 2026 10:38:08 +0200,
raoxu wrote:
> 
> From: Xu Rao <raoxu@uniontech.com>
> 
> print_conn_list() compares the raw hardware connection list with the
> connection list cached by the HDA driver.  When they differ, it prints an
> additional "In-driver Connection" line so that /proc/asound/card*/codec#*
> shows the topology actually used by the driver.
> 
> The comparison currently passes conn_len directly to memcmp().  However,
> conn_len is a number of connection-list entries, while memcmp() expects a
> size in bytes.  Both list and conn are arrays of hda_nid_t, which is u16,
> so only half of the connection data is compared.
> 
> For example, for two-entry lists such as:
> 
>   hardware: 0x0c 0x0d
>   cached:   0x0c 0x0e
> 
> conn_len is 2, and the current comparison checks only the first hda_nid_t.
> The lists are therefore incorrectly treated as identical even though the
> second connection differs.
> 
> This can happen legitimately when codec fixups replace a cached connection
> list with snd_hda_override_conn_list().  The codec routing used by the
> driver is not affected, but the proc output can hide the overridden
> driver-visible routing and provide misleading topology information during
> codec debugging.
> 
> Convert the entry count to a byte size so that memcmp() covers the
> complete connection list.
> 
> Fixes: 8b2c7a5c404d ("ALSA: hda - Add In-driver connection info")
> Signed-off-by: Xu Rao <raoxu@uniontech.com>

Thanks, applied now.


Takashi

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

end of thread, other threads:[~2026-08-18  9:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18  8:38 [PATCH] ALSA: hda: Fix connection list comparison in proc output raoxu
2026-08-18  9:41 ` Takashi Iwai

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