All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: lx6464es: add error handling for pci_ioremap_bar
@ 2018-06-12  3:23 ` Zhouyang Jia
  0 siblings, 0 replies; 8+ messages in thread
From: Zhouyang Jia @ 2018-06-12  3:23 UTC (permalink / raw)
  Cc: Zhouyang Jia, Jaroslav Kysela, Takashi Iwai, Bhumika Goyal,
	alsa-devel, linux-kernel

When pci_ioremap_bar fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling pci_ioremap_bar.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 sound/pci/lx6464es/lx6464es.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 9655b08..6157b6d 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -1016,6 +1016,10 @@ static int snd_lx6464es_create(struct snd_card *card,
 
 	/* dsp port */
 	chip->port_dsp_bar = pci_ioremap_bar(pci, 2);
+	if (!chip->port_dsp_bar) {
+		dev_err(card->dev, "cannot remap PCI memory region\n");
+		goto request_irq_failed;
+	}
 
 	err = request_threaded_irq(pci->irq, lx_interrupt, lx_threaded_irq,
 				   IRQF_SHARED, KBUILD_MODNAME, chip);
-- 
2.7.4


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

* [PATCH] ALSA: lx6464es: add error handling for pci_ioremap_bar
@ 2018-06-12  3:23 ` Zhouyang Jia
  0 siblings, 0 replies; 8+ messages in thread
From: Zhouyang Jia @ 2018-06-12  3:23 UTC (permalink / raw)
  Cc: Zhouyang Jia, Jaroslav Kysela, Takashi Iwai, Bhumika Goyal,
	alsa-devel, linux-kernel

When pci_ioremap_bar fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling pci_ioremap_bar.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 sound/pci/lx6464es/lx6464es.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 9655b08..6157b6d 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -1016,6 +1016,10 @@ static int snd_lx6464es_create(struct snd_card *card,
 
 	/* dsp port */
 	chip->port_dsp_bar = pci_ioremap_bar(pci, 2);
+	if (!chip->port_dsp_bar) {
+		dev_err(card->dev, "cannot remap PCI memory region\n");
+		goto request_irq_failed;
+	}
 
 	err = request_threaded_irq(pci->irq, lx_interrupt, lx_threaded_irq,
 				   IRQF_SHARED, KBUILD_MODNAME, chip);
-- 
2.7.4

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

* Re: [PATCH] ALSA: lx6464es: add error handling for pci_ioremap_bar
  2018-06-12  3:23 ` Zhouyang Jia
@ 2018-06-12  6:45   ` Takashi Iwai
  -1 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2018-06-12  6:45 UTC (permalink / raw)
  To: Zhouyang Jia; +Cc: alsa-devel, Bhumika Goyal, Jaroslav Kysela, linux-kernel

On Tue, 12 Jun 2018 05:23:14 +0200,
Zhouyang Jia wrote:
> 
> When pci_ioremap_bar fails, the lack of error-handling code may
> cause unexpected results.
> 
> This patch adds error-handling code after calling pci_ioremap_bar.
> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>

This patch makes no sense, sorry.  The whole lx6464es error handling
there is buggy.  We need to fix it more properly.

And, you must have noticed a bad smell in that change before
submitting this.  Basically, using the same goto label for the error
handling of the next step is already fishy.  In this case, you'd have
to unmap at the error path after this point.  If you can use the same
label, it means that the unmap is missing -- already something wrong.


thanks,

Takashi

> ---
>  sound/pci/lx6464es/lx6464es.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
> index 9655b08..6157b6d 100644
> --- a/sound/pci/lx6464es/lx6464es.c
> +++ b/sound/pci/lx6464es/lx6464es.c
> @@ -1016,6 +1016,10 @@ static int snd_lx6464es_create(struct snd_card *card,
>  
>  	/* dsp port */
>  	chip->port_dsp_bar = pci_ioremap_bar(pci, 2);
> +	if (!chip->port_dsp_bar) {
> +		dev_err(card->dev, "cannot remap PCI memory region\n");
> +		goto request_irq_failed;
> +	}
>  
>  	err = request_threaded_irq(pci->irq, lx_interrupt, lx_threaded_irq,
>  				   IRQF_SHARED, KBUILD_MODNAME, chip);
> -- 
> 2.7.4
> 
> 

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

* Re: [PATCH] ALSA: lx6464es: add error handling for pci_ioremap_bar
@ 2018-06-12  6:45   ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2018-06-12  6:45 UTC (permalink / raw)
  To: Zhouyang Jia; +Cc: alsa-devel, Bhumika Goyal, Jaroslav Kysela, linux-kernel

On Tue, 12 Jun 2018 05:23:14 +0200,
Zhouyang Jia wrote:
> 
> When pci_ioremap_bar fails, the lack of error-handling code may
> cause unexpected results.
> 
> This patch adds error-handling code after calling pci_ioremap_bar.
> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>

This patch makes no sense, sorry.  The whole lx6464es error handling
there is buggy.  We need to fix it more properly.

And, you must have noticed a bad smell in that change before
submitting this.  Basically, using the same goto label for the error
handling of the next step is already fishy.  In this case, you'd have
to unmap at the error path after this point.  If you can use the same
label, it means that the unmap is missing -- already something wrong.


thanks,

Takashi

> ---
>  sound/pci/lx6464es/lx6464es.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
> index 9655b08..6157b6d 100644
> --- a/sound/pci/lx6464es/lx6464es.c
> +++ b/sound/pci/lx6464es/lx6464es.c
> @@ -1016,6 +1016,10 @@ static int snd_lx6464es_create(struct snd_card *card,
>  
>  	/* dsp port */
>  	chip->port_dsp_bar = pci_ioremap_bar(pci, 2);
> +	if (!chip->port_dsp_bar) {
> +		dev_err(card->dev, "cannot remap PCI memory region\n");
> +		goto request_irq_failed;
> +	}
>  
>  	err = request_threaded_irq(pci->irq, lx_interrupt, lx_threaded_irq,
>  				   IRQF_SHARED, KBUILD_MODNAME, chip);
> -- 
> 2.7.4
> 
> 

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

* [PATCH v2] ALSA: lx6464es: add error handling for pci_ioremap_bar
  2018-06-12  3:23 ` Zhouyang Jia
@ 2018-06-14 13:51   ` Zhouyang Jia
  -1 siblings, 0 replies; 8+ messages in thread
From: Zhouyang Jia @ 2018-06-14 13:51 UTC (permalink / raw)
  Cc: Zhouyang Jia, Jaroslav Kysela, Takashi Iwai, Bhumika Goyal,
	alsa-devel, linux-kernel

When pci_ioremap_bar fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling pci_ioremap_bar.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
v1->v2:
- Add new goto label.
---
 sound/pci/lx6464es/lx6464es.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 9655b08..6c85f13 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -1016,6 +1016,10 @@ static int snd_lx6464es_create(struct snd_card *card,
 
 	/* dsp port */
 	chip->port_dsp_bar = pci_ioremap_bar(pci, 2);
+	if (!chip->port_dsp_bar) {
+		dev_err(card->dev, "cannot remap PCI memory region\n");
+		goto remap_pci_failed;
+	}
 
 	err = request_threaded_irq(pci->irq, lx_interrupt, lx_threaded_irq,
 				   IRQF_SHARED, KBUILD_MODNAME, chip);
@@ -1055,6 +1059,9 @@ static int snd_lx6464es_create(struct snd_card *card,
 	free_irq(pci->irq, chip);
 
 request_irq_failed:
+	iounmap(chip->port_dsp_bar);
+
+remap_pci_failed:
 	pci_release_regions(pci);
 
 request_regions_failed:
-- 
2.7.4


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

* [PATCH v2] ALSA: lx6464es: add error handling for pci_ioremap_bar
@ 2018-06-14 13:51   ` Zhouyang Jia
  0 siblings, 0 replies; 8+ messages in thread
From: Zhouyang Jia @ 2018-06-14 13:51 UTC (permalink / raw)
  Cc: Zhouyang Jia, Jaroslav Kysela, Takashi Iwai, Bhumika Goyal,
	alsa-devel, linux-kernel

When pci_ioremap_bar fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling pci_ioremap_bar.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
v1->v2:
- Add new goto label.
---
 sound/pci/lx6464es/lx6464es.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 9655b08..6c85f13 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -1016,6 +1016,10 @@ static int snd_lx6464es_create(struct snd_card *card,
 
 	/* dsp port */
 	chip->port_dsp_bar = pci_ioremap_bar(pci, 2);
+	if (!chip->port_dsp_bar) {
+		dev_err(card->dev, "cannot remap PCI memory region\n");
+		goto remap_pci_failed;
+	}
 
 	err = request_threaded_irq(pci->irq, lx_interrupt, lx_threaded_irq,
 				   IRQF_SHARED, KBUILD_MODNAME, chip);
@@ -1055,6 +1059,9 @@ static int snd_lx6464es_create(struct snd_card *card,
 	free_irq(pci->irq, chip);
 
 request_irq_failed:
+	iounmap(chip->port_dsp_bar);
+
+remap_pci_failed:
 	pci_release_regions(pci);
 
 request_regions_failed:
-- 
2.7.4

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

* Re: [PATCH v2] ALSA: lx6464es: add error handling for pci_ioremap_bar
  2018-06-14 13:51   ` Zhouyang Jia
@ 2018-06-14 16:01     ` Takashi Iwai
  -1 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2018-06-14 16:01 UTC (permalink / raw)
  To: Zhouyang Jia; +Cc: alsa-devel, Bhumika Goyal, Jaroslav Kysela, linux-kernel

On Thu, 14 Jun 2018 15:51:46 +0200,
Zhouyang Jia wrote:
> 
> When pci_ioremap_bar fails, the lack of error-handling code may
> cause unexpected results.
> 
> This patch adds error-handling code after calling pci_ioremap_bar.
> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> v1->v2:
> - Add new goto label.

Applied, thanks.


Takashi

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

* Re: [PATCH v2] ALSA: lx6464es: add error handling for pci_ioremap_bar
@ 2018-06-14 16:01     ` Takashi Iwai
  0 siblings, 0 replies; 8+ messages in thread
From: Takashi Iwai @ 2018-06-14 16:01 UTC (permalink / raw)
  To: Zhouyang Jia; +Cc: alsa-devel, Bhumika Goyal, Jaroslav Kysela, linux-kernel

On Thu, 14 Jun 2018 15:51:46 +0200,
Zhouyang Jia wrote:
> 
> When pci_ioremap_bar fails, the lack of error-handling code may
> cause unexpected results.
> 
> This patch adds error-handling code after calling pci_ioremap_bar.
> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> v1->v2:
> - Add new goto label.

Applied, thanks.


Takashi

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

end of thread, other threads:[~2018-06-14 16:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12  3:23 [PATCH] ALSA: lx6464es: add error handling for pci_ioremap_bar Zhouyang Jia
2018-06-12  3:23 ` Zhouyang Jia
2018-06-12  6:45 ` Takashi Iwai
2018-06-12  6:45   ` Takashi Iwai
2018-06-14 13:51 ` [PATCH v2] " Zhouyang Jia
2018-06-14 13:51   ` Zhouyang Jia
2018-06-14 16:01   ` Takashi Iwai
2018-06-14 16:01     ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.