Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: via82xx: Remove unreachable branch in  snd_via686_pcm_pointer()
@ 2026-07-06 13:16 Evgenii Burenchev
  2026-07-07 14:35 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Evgenii Burenchev @ 2026-07-06 13:16 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman
  Cc: Evgenii Burenchev, perex, tiwai, u.kleine-koenig, kees,
	linux-sound, linux-kernel, lvc-project

The condition

	if (count && size < count)

can never evaluate to true.

The VIA DMA count register is masked with 0x00ffffff before use, while
the DMA buffer size is limited to 0x00fffffe bytes. As a result, 'count'
can never exceed 'size', making the condition permanently false.

This branch has therefore been unreachable since the driver was
introduced. Remove the unreachable branch without changing runtime
behavior.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>
---
 sound/pci/via82xx_modem.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 9b84d3fb9eaf..b32f84ac17cc 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -573,24 +573,18 @@ static inline unsigned int calc_linear_pos(struct via82xx_modem *chip,
 		       viadev->bufsize2, viadev->idx_table[idx].offset,
 		       viadev->idx_table[idx].size, count);
 #endif
-		if (count && size < count) {
+		if (! count)
+			/* bogus count 0 on the DMA boundary? */
+			res = viadev->idx_table[idx].offset;
+		else
+			/* count register returns full size
+			 * when end of buffer is reached
+			 */
+			res = viadev->idx_table[idx].offset + size;
+		if (check_invalid_pos(viadev, res)) {
 			dev_dbg(chip->card->dev,
-				"invalid via82xx_cur_ptr, using last valid pointer\n");
+				"invalid via82xx_cur_ptr (2), using last valid pointer\n");
 			res = viadev->lastpos;
-		} else {
-			if (! count)
-				/* bogus count 0 on the DMA boundary? */
-				res = viadev->idx_table[idx].offset;
-			else
-				/* count register returns full size
-				 * when end of buffer is reached
-				 */
-				res = viadev->idx_table[idx].offset + size;
-			if (check_invalid_pos(viadev, res)) {
-				dev_dbg(chip->card->dev,
-					"invalid via82xx_cur_ptr (2), using last valid pointer\n");
-				res = viadev->lastpos;
-			}
 		}
 	}
 	viadev->lastpos = res; /* remember the last position */
-- 
2.43.0


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

* Re: [PATCH] ALSA: via82xx: Remove unreachable branch in  snd_via686_pcm_pointer()
  2026-07-06 13:16 [PATCH] ALSA: via82xx: Remove unreachable branch in snd_via686_pcm_pointer() Evgenii Burenchev
@ 2026-07-07 14:35 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-07-07 14:35 UTC (permalink / raw)
  To: Evgenii Burenchev
  Cc: stable, Greg Kroah-Hartman, perex, tiwai, u.kleine-koenig, kees,
	linux-sound, linux-kernel, lvc-project

On Mon, 06 Jul 2026 15:16:34 +0200,
Evgenii Burenchev wrote:
> 
> The condition
> 
> 	if (count && size < count)
> 
> can never evaluate to true.
> 
> The VIA DMA count register is masked with 0x00ffffff before use, while
> the DMA buffer size is limited to 0x00fffffe bytes. As a result, 'count'
> can never exceed 'size', making the condition permanently false.
> 
> This branch has therefore been unreachable since the driver was
> introduced. Remove the unreachable branch without changing runtime
> behavior.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>

Applied now.  Thanks.


Takashi

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

end of thread, other threads:[~2026-07-07 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 13:16 [PATCH] ALSA: via82xx: Remove unreachable branch in snd_via686_pcm_pointer() Evgenii Burenchev
2026-07-07 14:35 ` Takashi Iwai

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