All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sb16: request_region failure ignored in snd_sb16_isa_probe1()
@ 2009-09-21 10:03 Roel Kluin
  2009-09-21 10:33 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-09-21 10:03 UTC (permalink / raw)
  To: Takashi Iwai, alsa-devel, Andrew Morton

request_region() may fail. clean up if it does,
also a release region later on was missing.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Found with sed: http://kernelnewbies.org/roelkluin

build, sparse and checkpatch tested.

diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
index 519c363..f50ed6f 100644
--- a/sound/isa/sb/sb16.c
+++ b/sound/isa/sb/sb16.c
@@ -502,6 +502,11 @@ static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev)
 	fm_port[dev] = port[dev];
 	/* block the 0x388 port to avoid PnP conflicts */
 	acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
+	if (acard->fm_res == NULL) {
+		snd_card_free(card);
+		return -ENOMEM;
+	}
+
 #ifdef SNDRV_SBAWE_EMU8000
 	/* non-PnP AWE port address is hardwired with base port address */
 	awe_port[dev] = port[dev] + 0x400;
@@ -509,6 +514,7 @@ static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev)
 
 	snd_card_set_dev(card, pdev);
 	if ((err = snd_sb16_probe(card, dev)) < 0) {
+		release_region(0x388, 4);
 		snd_card_free(card);
 		return err;
 	}

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

* Re: [PATCH] sb16: request_region failure ignored in snd_sb16_isa_probe1()
  2009-09-21 10:03 [PATCH] sb16: request_region failure ignored in snd_sb16_isa_probe1() Roel Kluin
@ 2009-09-21 10:33 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2009-09-21 10:33 UTC (permalink / raw)
  To: Roel Kluin; +Cc: alsa-devel, Andrew Morton

At Mon, 21 Sep 2009 12:03:47 +0200,
Roel Kluin wrote:
> 
> request_region() may fail. clean up if it does,
> also a release region later on was missing.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> Found with sed: http://kernelnewbies.org/roelkluin
> 
> build, sparse and checkpatch tested.

Thanks for the patch.  But, it looks incorrect.
The resource acard->fm_res is released properly in the destructor
callback (snd_sb16_free()).

Also, acard->fm_res == NULL is no critical error and can be accepted
as is.


Takashi


> diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c
> index 519c363..f50ed6f 100644
> --- a/sound/isa/sb/sb16.c
> +++ b/sound/isa/sb/sb16.c
> @@ -502,6 +502,11 @@ static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev)
>  	fm_port[dev] = port[dev];
>  	/* block the 0x388 port to avoid PnP conflicts */
>  	acard->fm_res = request_region(0x388, 4, "SoundBlaster FM");
> +	if (acard->fm_res == NULL) {
> +		snd_card_free(card);
> +		return -ENOMEM;
> +	}
> +
>  #ifdef SNDRV_SBAWE_EMU8000
>  	/* non-PnP AWE port address is hardwired with base port address */
>  	awe_port[dev] = port[dev] + 0x400;
> @@ -509,6 +514,7 @@ static int __devinit snd_sb16_isa_probe1(int dev, struct device *pdev)
>  
>  	snd_card_set_dev(card, pdev);
>  	if ((err = snd_sb16_probe(card, dev)) < 0) {
> +		release_region(0x388, 4);
>  		snd_card_free(card);
>  		return err;
>  	}
> 

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

end of thread, other threads:[~2009-09-21 10:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-21 10:03 [PATCH] sb16: request_region failure ignored in snd_sb16_isa_probe1() Roel Kluin
2009-09-21 10:33 ` 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.