Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: au88x0: Fix incorrect error handling for PCI config reads
@ 2025-11-17  6:55 Haotian Zhang
  2025-11-17  7:04 ` Philipp Stanner
  2025-11-17 16:24 ` Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Haotian Zhang @ 2025-11-17  6:55 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: Philipp Stanner, linux-sound, linux-kernel, Haotian Zhang

__snd_vortex_probe() uses pci_read_config_word() that returns PCIBIOS_*
codes (positive values on error). However, the function checks 'err < 0'
which can never be true for PCIBIOS_* codes, causing errors to be silently
ignored.

Check for non-zero return value and convert PCIBIOS_* codes using
pcibios_err_to_errno() into normal errno before returning them.

Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 sound/pci/au88x0/au88x0.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index de56e83d8e10..bb02945793f0 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -280,11 +280,11 @@ __snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
 
 	// (5)
 	err = pci_read_config_word(pci, PCI_DEVICE_ID, &chip->device);
-	if (err < 0)
-		return err;
+	if (err)
+		return pcibios_err_to_errno(err);
 	err = pci_read_config_word(pci, PCI_VENDOR_ID, &chip->vendor);
-	if (err < 0)
-		return err;
+	if (err)
+		return pcibios_err_to_errno(err);
 	chip->rev = pci->revision;
 #ifdef CHIP_AU8830
 	if ((chip->rev) != 0xfe && (chip->rev) != 0xfa) {
-- 
2.50.1.windows.1


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

* Re: [PATCH] ALSA: au88x0: Fix incorrect error handling for PCI config reads
  2025-11-17  6:55 [PATCH] ALSA: au88x0: Fix incorrect error handling for PCI config reads Haotian Zhang
@ 2025-11-17  7:04 ` Philipp Stanner
  2025-11-17 16:24 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Philipp Stanner @ 2025-11-17  7:04 UTC (permalink / raw)
  To: Haotian Zhang, Jaroslav Kysela, Takashi Iwai
  Cc: Philipp Stanner, linux-sound, linux-kernel

On Mon, 2025-11-17 at 14:55 +0800, Haotian Zhang wrote:
> __snd_vortex_probe() uses pci_read_config_word() that returns PCIBIOS_*
> codes (positive values on error). However, the function checks 'err < 0'
> which can never be true for PCIBIOS_* codes, causing errors to be silently
> ignored.
> 
> Check for non-zero return value and convert PCIBIOS_* codes using
> pcibios_err_to_errno() into normal errno before returning them.
> 
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>

Reviewed-by: Philipp Stanner <phasta@kernel.org>

> ---
>  sound/pci/au88x0/au88x0.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
> index de56e83d8e10..bb02945793f0 100644
> --- a/sound/pci/au88x0/au88x0.c
> +++ b/sound/pci/au88x0/au88x0.c
> @@ -280,11 +280,11 @@ __snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
>  
>  	// (5)
>  	err = pci_read_config_word(pci, PCI_DEVICE_ID, &chip->device);
> -	if (err < 0)
> -		return err;
> +	if (err)
> +		return pcibios_err_to_errno(err);
>  	err = pci_read_config_word(pci, PCI_VENDOR_ID, &chip->vendor);
> -	if (err < 0)
> -		return err;
> +	if (err)
> +		return pcibios_err_to_errno(err);
>  	chip->rev = pci->revision;
>  #ifdef CHIP_AU8830
>  	if ((chip->rev) != 0xfe && (chip->rev) != 0xfa) {


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

* Re: [PATCH] ALSA: au88x0: Fix incorrect error handling for PCI config reads
  2025-11-17  6:55 [PATCH] ALSA: au88x0: Fix incorrect error handling for PCI config reads Haotian Zhang
  2025-11-17  7:04 ` Philipp Stanner
@ 2025-11-17 16:24 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2025-11-17 16:24 UTC (permalink / raw)
  To: Haotian Zhang
  Cc: Jaroslav Kysela, Takashi Iwai, Philipp Stanner, linux-sound,
	linux-kernel

On Mon, 17 Nov 2025 07:55:59 +0100,
Haotian Zhang wrote:
> 
> __snd_vortex_probe() uses pci_read_config_word() that returns PCIBIOS_*
> codes (positive values on error). However, the function checks 'err < 0'
> which can never be true for PCIBIOS_* codes, causing errors to be silently
> ignored.
> 
> Check for non-zero return value and convert PCIBIOS_* codes using
> pcibios_err_to_errno() into normal errno before returning them.
> 
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>

Applied now.  Thanks.


Takashi

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

end of thread, other threads:[~2025-11-17 16:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17  6:55 [PATCH] ALSA: au88x0: Fix incorrect error handling for PCI config reads Haotian Zhang
2025-11-17  7:04 ` Philipp Stanner
2025-11-17 16:24 ` Takashi Iwai

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