All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ALSA: korg1212: Fine-tuning for three function implementations
@ 2017-11-16 11:50 ` SF Markus Elfring
  0 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:50 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 12:42:42 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Adjust eight function calls together with a variable assignment
  Delete a duplicate function call "release_firmware" in snd_korg1212_create()
  Use common error handling code in two functions

 sound/pci/korg1212/korg1212.c | 85 ++++++++++++++++++++++++-------------------
 1 file changed, 47 insertions(+), 38 deletions(-)

-- 
2.15.0

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

* [PATCH 0/3] ALSA: korg1212: Fine-tuning for three function implementations
@ 2017-11-16 11:50 ` SF Markus Elfring
  0 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:50 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 12:42:42 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Adjust eight function calls together with a variable assignment
  Delete a duplicate function call "release_firmware" in snd_korg1212_create()
  Use common error handling code in two functions

 sound/pci/korg1212/korg1212.c | 85 ++++++++++++++++++++++++-------------------
 1 file changed, 47 insertions(+), 38 deletions(-)

-- 
2.15.0


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

* [PATCH 0/3] ALSA: korg1212: Fine-tuning for three function implementations
@ 2017-11-16 11:50 ` SF Markus Elfring
  0 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:50 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 12:42:42 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Adjust eight function calls together with a variable assignment
  Delete a duplicate function call "release_firmware" in snd_korg1212_create()
  Use common error handling code in two functions

 sound/pci/korg1212/korg1212.c | 85 ++++++++++++++++++++++++-------------------
 1 file changed, 47 insertions(+), 38 deletions(-)

-- 
2.15.0

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

* [PATCH 1/3] ALSA: korg1212: Adjust eight function calls together with a variable assignment
  2017-11-16 11:50 ` SF Markus Elfring
  (?)
@ 2017-11-16 11:51   ` SF Markus Elfring
  -1 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:51 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 09:42:45 +0100

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/korg1212/korg1212.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index c7b007164c99..6dde8c215b48 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -1542,7 +1542,8 @@ static int snd_korg1212_hw_params(struct snd_pcm_substream *substream,
 	        return 0;
 	}
 
-        if ((err = snd_korg1212_SetRate(korg1212, params_rate(params))) < 0) {
+	err = snd_korg1212_SetRate(korg1212, params_rate(params));
+	if (err < 0) {
                 spin_unlock_irqrestore(&korg1212->lock, flags);
                 return err;
         }
@@ -2174,8 +2175,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         };
 
         * rchip = NULL;
-        if ((err = pci_enable_device(pci)) < 0)
-                return err;
+	err = pci_enable_device(pci);
+	if (err < 0)
+		return err;
 
         korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);
         if (korg1212 == NULL) {
@@ -2211,7 +2213,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         for (i=0; i<kAudioChannels; i++)
                 korg1212->volumePhase[i] = 0;
 
-	if ((err = pci_request_regions(pci, "korg1212")) < 0) {
+	err = pci_request_regions(pci, "korg1212");
+	if (err < 0) {
 		kfree(korg1212);
 		pci_disable_device(pci);
 		return err;
@@ -2235,7 +2238,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 		   korg1212->iomem2, iomem2_size,
 		   stateName[korg1212->cardState]);
 
-        if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) {
+	korg1212->iobase = ioremap(korg1212->iomem, iomem_size);
+	if (!korg1212->iobase) {
 		snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
                            korg1212->iomem + iomem_size - 1);
                 snd_korg1212_free(korg1212);
@@ -2375,7 +2379,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (rc)
 		K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
 
-        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) {
+	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops);
+	if (err < 0) {
                 snd_korg1212_free(korg1212);
                 return err;
         }
@@ -2400,8 +2405,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
                korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy),
                korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy));
 
-        if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0)
-                return err;
+	err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm);
+	if (err < 0)
+		return err;
 
 	korg1212->pcm->private_data = korg1212;
         korg1212->pcm->private_free = snd_korg1212_free_pcm;
@@ -2451,7 +2457,8 @@ snd_korg1212_probe(struct pci_dev *pci,
 	if (err < 0)
 		return err;
 
-        if ((err = snd_korg1212_create(card, pci, &korg1212)) < 0) {
+	err = snd_korg1212_create(card, pci, &korg1212);
+	if (err < 0) {
 		snd_card_free(card);
 		return err;
 	}
@@ -2463,7 +2470,8 @@ snd_korg1212_probe(struct pci_dev *pci,
 
         K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname);
 
-	if ((err = snd_card_register(card)) < 0) {
+	err = snd_card_register(card);
+	if (err < 0) {
 		snd_card_free(card);
 		return err;
 	}
-- 
2.15.0

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

* [PATCH 1/3] ALSA: korg1212: Adjust eight function calls together with a variable assignment
@ 2017-11-16 11:51   ` SF Markus Elfring
  0 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:51 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 09:42:45 +0100

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/korg1212/korg1212.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index c7b007164c99..6dde8c215b48 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -1542,7 +1542,8 @@ static int snd_korg1212_hw_params(struct snd_pcm_substream *substream,
 	        return 0;
 	}
 
-        if ((err = snd_korg1212_SetRate(korg1212, params_rate(params))) < 0) {
+	err = snd_korg1212_SetRate(korg1212, params_rate(params));
+	if (err < 0) {
                 spin_unlock_irqrestore(&korg1212->lock, flags);
                 return err;
         }
@@ -2174,8 +2175,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         };
 
         * rchip = NULL;
-        if ((err = pci_enable_device(pci)) < 0)
-                return err;
+	err = pci_enable_device(pci);
+	if (err < 0)
+		return err;
 
         korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);
         if (korg1212 = NULL) {
@@ -2211,7 +2213,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         for (i=0; i<kAudioChannels; i++)
                 korg1212->volumePhase[i] = 0;
 
-	if ((err = pci_request_regions(pci, "korg1212")) < 0) {
+	err = pci_request_regions(pci, "korg1212");
+	if (err < 0) {
 		kfree(korg1212);
 		pci_disable_device(pci);
 		return err;
@@ -2235,7 +2238,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 		   korg1212->iomem2, iomem2_size,
 		   stateName[korg1212->cardState]);
 
-        if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) = NULL) {
+	korg1212->iobase = ioremap(korg1212->iomem, iomem_size);
+	if (!korg1212->iobase) {
 		snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
                            korg1212->iomem + iomem_size - 1);
                 snd_korg1212_free(korg1212);
@@ -2375,7 +2379,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (rc)
 		K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
 
-        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) {
+	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops);
+	if (err < 0) {
                 snd_korg1212_free(korg1212);
                 return err;
         }
@@ -2400,8 +2405,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
                korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy),
                korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy));
 
-        if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0)
-                return err;
+	err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm);
+	if (err < 0)
+		return err;
 
 	korg1212->pcm->private_data = korg1212;
         korg1212->pcm->private_free = snd_korg1212_free_pcm;
@@ -2451,7 +2457,8 @@ snd_korg1212_probe(struct pci_dev *pci,
 	if (err < 0)
 		return err;
 
-        if ((err = snd_korg1212_create(card, pci, &korg1212)) < 0) {
+	err = snd_korg1212_create(card, pci, &korg1212);
+	if (err < 0) {
 		snd_card_free(card);
 		return err;
 	}
@@ -2463,7 +2470,8 @@ snd_korg1212_probe(struct pci_dev *pci,
 
         K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname);
 
-	if ((err = snd_card_register(card)) < 0) {
+	err = snd_card_register(card);
+	if (err < 0) {
 		snd_card_free(card);
 		return err;
 	}
-- 
2.15.0


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

* [PATCH 1/3] ALSA: korg1212: Adjust eight function calls together with a variable assignment
@ 2017-11-16 11:51   ` SF Markus Elfring
  0 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:51 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 09:42:45 +0100

The script "checkpatch.pl" pointed information out like the following.

ERROR: do not use assignment in if condition

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/korg1212/korg1212.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index c7b007164c99..6dde8c215b48 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -1542,7 +1542,8 @@ static int snd_korg1212_hw_params(struct snd_pcm_substream *substream,
 	        return 0;
 	}
 
-        if ((err = snd_korg1212_SetRate(korg1212, params_rate(params))) < 0) {
+	err = snd_korg1212_SetRate(korg1212, params_rate(params));
+	if (err < 0) {
                 spin_unlock_irqrestore(&korg1212->lock, flags);
                 return err;
         }
@@ -2174,8 +2175,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         };
 
         * rchip = NULL;
-        if ((err = pci_enable_device(pci)) < 0)
-                return err;
+	err = pci_enable_device(pci);
+	if (err < 0)
+		return err;
 
         korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);
         if (korg1212 == NULL) {
@@ -2211,7 +2213,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         for (i=0; i<kAudioChannels; i++)
                 korg1212->volumePhase[i] = 0;
 
-	if ((err = pci_request_regions(pci, "korg1212")) < 0) {
+	err = pci_request_regions(pci, "korg1212");
+	if (err < 0) {
 		kfree(korg1212);
 		pci_disable_device(pci);
 		return err;
@@ -2235,7 +2238,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 		   korg1212->iomem2, iomem2_size,
 		   stateName[korg1212->cardState]);
 
-        if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) {
+	korg1212->iobase = ioremap(korg1212->iomem, iomem_size);
+	if (!korg1212->iobase) {
 		snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
                            korg1212->iomem + iomem_size - 1);
                 snd_korg1212_free(korg1212);
@@ -2375,7 +2379,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (rc)
 		K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
 
-        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) {
+	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops);
+	if (err < 0) {
                 snd_korg1212_free(korg1212);
                 return err;
         }
@@ -2400,8 +2405,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
                korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy),
                korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy));
 
-        if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0)
-                return err;
+	err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm);
+	if (err < 0)
+		return err;
 
 	korg1212->pcm->private_data = korg1212;
         korg1212->pcm->private_free = snd_korg1212_free_pcm;
@@ -2451,7 +2457,8 @@ snd_korg1212_probe(struct pci_dev *pci,
 	if (err < 0)
 		return err;
 
-        if ((err = snd_korg1212_create(card, pci, &korg1212)) < 0) {
+	err = snd_korg1212_create(card, pci, &korg1212);
+	if (err < 0) {
 		snd_card_free(card);
 		return err;
 	}
@@ -2463,7 +2470,8 @@ snd_korg1212_probe(struct pci_dev *pci,
 
         K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname);
 
-	if ((err = snd_card_register(card)) < 0) {
+	err = snd_card_register(card);
+	if (err < 0) {
 		snd_card_free(card);
 		return err;
 	}
-- 
2.15.0

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

* [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_create()
  2017-11-16 11:50 ` SF Markus Elfring
  (?)
@ 2017-11-16 11:52   ` SF Markus Elfring
  -1 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:52 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 11:22:26 +0100

The function "release_firmware" is called in the current implementation of
the function "_request_firmware" after a failure was detected.
Link: https://elixir.free-electrons.com/linux/v4.14-rc8/source/drivers/base/firmware_class.c#L1196

Such a call should therefore not be repeated directly after the
corresponding error information was received in the local variable "err"
of the function "snd_korg1212_create".
Thus remove a misplaced function call.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/korg1212/korg1212.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 6dde8c215b48..dc701519d219 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2352,7 +2352,6 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
 	err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
 	if (err < 0) {
-		release_firmware(dsp_code);
 		snd_printk(KERN_ERR "firmware not available\n");
 		snd_korg1212_free(korg1212);
 		return err;
-- 
2.15.0

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

* [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_crea
@ 2017-11-16 11:52   ` SF Markus Elfring
  0 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:52 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 11:22:26 +0100

The function "release_firmware" is called in the current implementation of
the function "_request_firmware" after a failure was detected.
Link: https://elixir.free-electrons.com/linux/v4.14-rc8/source/drivers/base/firmware_class.c#L1196

Such a call should therefore not be repeated directly after the
corresponding error information was received in the local variable "err"
of the function "snd_korg1212_create".
Thus remove a misplaced function call.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/korg1212/korg1212.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 6dde8c215b48..dc701519d219 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2352,7 +2352,6 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
 	err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
 	if (err < 0) {
-		release_firmware(dsp_code);
 		snd_printk(KERN_ERR "firmware not available\n");
 		snd_korg1212_free(korg1212);
 		return err;
-- 
2.15.0


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

* [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_create()
@ 2017-11-16 11:52   ` SF Markus Elfring
  0 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:52 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 11:22:26 +0100

The function "release_firmware" is called in the current implementation of
the function "_request_firmware" after a failure was detected.
Link: https://elixir.free-electrons.com/linux/v4.14-rc8/source/drivers/base/firmware_class.c#L1196

Such a call should therefore not be repeated directly after the
corresponding error information was received in the local variable "err"
of the function "snd_korg1212_create".
Thus remove a misplaced function call.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/korg1212/korg1212.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 6dde8c215b48..dc701519d219 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2352,7 +2352,6 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
 	err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
 	if (err < 0) {
-		release_firmware(dsp_code);
 		snd_printk(KERN_ERR "firmware not available\n");
 		snd_korg1212_free(korg1212);
 		return err;
-- 
2.15.0

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

* [PATCH 3/3] ALSA: korg1212: Use common error handling code in two functions
  2017-11-16 11:50 ` SF Markus Elfring
  (?)
@ 2017-11-16 11:53   ` SF Markus Elfring
  -1 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:53 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 11:55:58 +0100

Add jump targets so that a bit of exception handling can be better reused
at the end of these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/korg1212/korg1212.c | 62 ++++++++++++++++++++++---------------------
 1 file changed, 32 insertions(+), 30 deletions(-)

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index dc701519d219..b908c7c986ab 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2181,8 +2181,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
         korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);
         if (korg1212 == NULL) {
-		pci_disable_device(pci);
-                return -ENOMEM;
+		err = -ENOMEM;
+		goto disable_device;
 	}
 
 	korg1212->card = card;
@@ -2216,8 +2216,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	err = pci_request_regions(pci, "korg1212");
 	if (err < 0) {
 		kfree(korg1212);
-		pci_disable_device(pci);
-		return err;
+		goto disable_device;
 	}
 
         korg1212->iomem = pci_resource_start(korg1212->pci, 0);
@@ -2242,8 +2241,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (!korg1212->iobase) {
 		snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
                            korg1212->iomem + iomem_size - 1);
-                snd_korg1212_free(korg1212);
-                return -EBUSY;
+		err = -EBUSY;
+		goto free_sound_chip;
         }
 
         err = request_irq(pci->irq, snd_korg1212_interrupt,
@@ -2252,8 +2251,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
         if (err) {
 		snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq);
-                snd_korg1212_free(korg1212);
-                return -EBUSY;
+		err = -EBUSY;
+		goto free_sound_chip;
         }
 
         korg1212->irq = pci->irq;
@@ -2298,8 +2297,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) {
 		snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%zd bytes)\n", sizeof(struct KorgSharedBuffer));
-                snd_korg1212_free(korg1212);
-                return -ENOMEM;
+		goto e_nomem;
         }
         korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area;
         korg1212->sharedBufferPhy = korg1212->dma_shared.addr;
@@ -2313,8 +2311,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				korg1212->DataBufsSize, &korg1212->dma_play) < 0) {
 		snd_printk(KERN_ERR "korg1212: can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
-                snd_korg1212_free(korg1212);
-                return -ENOMEM;
+		goto e_nomem;
         }
 	korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area;
 	korg1212->PlayDataPhy = korg1212->dma_play.addr;
@@ -2325,8 +2322,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
 		snd_printk(KERN_ERR "korg1212: can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
-                snd_korg1212_free(korg1212);
-                return -ENOMEM;
+		goto e_nomem;
         }
         korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area;
         korg1212->RecDataPhy = korg1212->dma_rec.addr;
@@ -2353,16 +2349,14 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
 	if (err < 0) {
 		snd_printk(KERN_ERR "firmware not available\n");
-		snd_korg1212_free(korg1212);
-		return err;
+		goto free_sound_chip;
 	}
 
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				dsp_code->size, &korg1212->dma_dsp) < 0) {
 		snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
-                snd_korg1212_free(korg1212);
 		release_firmware(dsp_code);
-                return -ENOMEM;
+		goto e_nomem;
         }
 
         K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n",
@@ -2379,10 +2373,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 		K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
 
 	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops);
-	if (err < 0) {
-                snd_korg1212_free(korg1212);
-                return err;
-        }
+	if (err < 0)
+		goto free_sound_chip;
         
 	snd_korg1212_EnableCardInterrupts(korg1212);
 
@@ -2429,6 +2421,15 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         * rchip = korg1212;
 	return 0;
 
+disable_device:
+	pci_disable_device(pci);
+	return err;
+
+e_nomem:
+	err = -ENOMEM;
+free_sound_chip:
+	snd_korg1212_free(korg1212);
+	return err;
 }
 
 /*
@@ -2457,10 +2458,8 @@ snd_korg1212_probe(struct pci_dev *pci,
 		return err;
 
 	err = snd_korg1212_create(card, pci, &korg1212);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	strcpy(card->driver, "korg1212");
 	strcpy(card->shortname, "korg1212");
@@ -2470,13 +2469,16 @@ snd_korg1212_probe(struct pci_dev *pci,
         K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname);
 
 	err = snd_card_register(card);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
+
 	pci_set_drvdata(pci, card);
 	dev++;
 	return 0;
+
+free_card:
+	snd_card_free(card);
+	return err;
 }
 
 static void snd_korg1212_remove(struct pci_dev *pci)
-- 
2.15.0

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

* [PATCH 3/3] ALSA: korg1212: Use common error handling code in two functions
@ 2017-11-16 11:53   ` SF Markus Elfring
  0 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:53 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 11:55:58 +0100

Add jump targets so that a bit of exception handling can be better reused
at the end of these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/korg1212/korg1212.c | 62 ++++++++++++++++++++++---------------------
 1 file changed, 32 insertions(+), 30 deletions(-)

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index dc701519d219..b908c7c986ab 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2181,8 +2181,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
         korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);
         if (korg1212 = NULL) {
-		pci_disable_device(pci);
-                return -ENOMEM;
+		err = -ENOMEM;
+		goto disable_device;
 	}
 
 	korg1212->card = card;
@@ -2216,8 +2216,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	err = pci_request_regions(pci, "korg1212");
 	if (err < 0) {
 		kfree(korg1212);
-		pci_disable_device(pci);
-		return err;
+		goto disable_device;
 	}
 
         korg1212->iomem = pci_resource_start(korg1212->pci, 0);
@@ -2242,8 +2241,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (!korg1212->iobase) {
 		snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
                            korg1212->iomem + iomem_size - 1);
-                snd_korg1212_free(korg1212);
-                return -EBUSY;
+		err = -EBUSY;
+		goto free_sound_chip;
         }
 
         err = request_irq(pci->irq, snd_korg1212_interrupt,
@@ -2252,8 +2251,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
         if (err) {
 		snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq);
-                snd_korg1212_free(korg1212);
-                return -EBUSY;
+		err = -EBUSY;
+		goto free_sound_chip;
         }
 
         korg1212->irq = pci->irq;
@@ -2298,8 +2297,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) {
 		snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%zd bytes)\n", sizeof(struct KorgSharedBuffer));
-                snd_korg1212_free(korg1212);
-                return -ENOMEM;
+		goto e_nomem;
         }
         korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area;
         korg1212->sharedBufferPhy = korg1212->dma_shared.addr;
@@ -2313,8 +2311,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				korg1212->DataBufsSize, &korg1212->dma_play) < 0) {
 		snd_printk(KERN_ERR "korg1212: can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
-                snd_korg1212_free(korg1212);
-                return -ENOMEM;
+		goto e_nomem;
         }
 	korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area;
 	korg1212->PlayDataPhy = korg1212->dma_play.addr;
@@ -2325,8 +2322,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
 		snd_printk(KERN_ERR "korg1212: can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
-                snd_korg1212_free(korg1212);
-                return -ENOMEM;
+		goto e_nomem;
         }
         korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area;
         korg1212->RecDataPhy = korg1212->dma_rec.addr;
@@ -2353,16 +2349,14 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
 	if (err < 0) {
 		snd_printk(KERN_ERR "firmware not available\n");
-		snd_korg1212_free(korg1212);
-		return err;
+		goto free_sound_chip;
 	}
 
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				dsp_code->size, &korg1212->dma_dsp) < 0) {
 		snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
-                snd_korg1212_free(korg1212);
 		release_firmware(dsp_code);
-                return -ENOMEM;
+		goto e_nomem;
         }
 
         K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n",
@@ -2379,10 +2373,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 		K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
 
 	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops);
-	if (err < 0) {
-                snd_korg1212_free(korg1212);
-                return err;
-        }
+	if (err < 0)
+		goto free_sound_chip;
         
 	snd_korg1212_EnableCardInterrupts(korg1212);
 
@@ -2429,6 +2421,15 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         * rchip = korg1212;
 	return 0;
 
+disable_device:
+	pci_disable_device(pci);
+	return err;
+
+e_nomem:
+	err = -ENOMEM;
+free_sound_chip:
+	snd_korg1212_free(korg1212);
+	return err;
 }
 
 /*
@@ -2457,10 +2458,8 @@ snd_korg1212_probe(struct pci_dev *pci,
 		return err;
 
 	err = snd_korg1212_create(card, pci, &korg1212);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	strcpy(card->driver, "korg1212");
 	strcpy(card->shortname, "korg1212");
@@ -2470,13 +2469,16 @@ snd_korg1212_probe(struct pci_dev *pci,
         K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname);
 
 	err = snd_card_register(card);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
+
 	pci_set_drvdata(pci, card);
 	dev++;
 	return 0;
+
+free_card:
+	snd_card_free(card);
+	return err;
 }
 
 static void snd_korg1212_remove(struct pci_dev *pci)
-- 
2.15.0


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

* [PATCH 3/3] ALSA: korg1212: Use common error handling code in two functions
@ 2017-11-16 11:53   ` SF Markus Elfring
  0 siblings, 0 replies; 15+ messages in thread
From: SF Markus Elfring @ 2017-11-16 11:53 UTC (permalink / raw)
  To: alsa-devel, Alexey Dobriyan, Andrew Morton, Bhumika Goyal,
	Jaroslav Kysela, Kees Cook, Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 16 Nov 2017 11:55:58 +0100

Add jump targets so that a bit of exception handling can be better reused
at the end of these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/pci/korg1212/korg1212.c | 62 ++++++++++++++++++++++---------------------
 1 file changed, 32 insertions(+), 30 deletions(-)

diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index dc701519d219..b908c7c986ab 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2181,8 +2181,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
         korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);
         if (korg1212 == NULL) {
-		pci_disable_device(pci);
-                return -ENOMEM;
+		err = -ENOMEM;
+		goto disable_device;
 	}
 
 	korg1212->card = card;
@@ -2216,8 +2216,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	err = pci_request_regions(pci, "korg1212");
 	if (err < 0) {
 		kfree(korg1212);
-		pci_disable_device(pci);
-		return err;
+		goto disable_device;
 	}
 
         korg1212->iomem = pci_resource_start(korg1212->pci, 0);
@@ -2242,8 +2241,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (!korg1212->iobase) {
 		snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
                            korg1212->iomem + iomem_size - 1);
-                snd_korg1212_free(korg1212);
-                return -EBUSY;
+		err = -EBUSY;
+		goto free_sound_chip;
         }
 
         err = request_irq(pci->irq, snd_korg1212_interrupt,
@@ -2252,8 +2251,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 
         if (err) {
 		snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq);
-                snd_korg1212_free(korg1212);
-                return -EBUSY;
+		err = -EBUSY;
+		goto free_sound_chip;
         }
 
         korg1212->irq = pci->irq;
@@ -2298,8 +2297,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) {
 		snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%zd bytes)\n", sizeof(struct KorgSharedBuffer));
-                snd_korg1212_free(korg1212);
-                return -ENOMEM;
+		goto e_nomem;
         }
         korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area;
         korg1212->sharedBufferPhy = korg1212->dma_shared.addr;
@@ -2313,8 +2311,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				korg1212->DataBufsSize, &korg1212->dma_play) < 0) {
 		snd_printk(KERN_ERR "korg1212: can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
-                snd_korg1212_free(korg1212);
-                return -ENOMEM;
+		goto e_nomem;
         }
 	korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area;
 	korg1212->PlayDataPhy = korg1212->dma_play.addr;
@@ -2325,8 +2322,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
 		snd_printk(KERN_ERR "korg1212: can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
-                snd_korg1212_free(korg1212);
-                return -ENOMEM;
+		goto e_nomem;
         }
         korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area;
         korg1212->RecDataPhy = korg1212->dma_rec.addr;
@@ -2353,16 +2349,14 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 	err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev);
 	if (err < 0) {
 		snd_printk(KERN_ERR "firmware not available\n");
-		snd_korg1212_free(korg1212);
-		return err;
+		goto free_sound_chip;
 	}
 
 	if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
 				dsp_code->size, &korg1212->dma_dsp) < 0) {
 		snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
-                snd_korg1212_free(korg1212);
 		release_firmware(dsp_code);
-                return -ENOMEM;
+		goto e_nomem;
         }
 
         K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n",
@@ -2379,10 +2373,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
 		K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
 
 	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops);
-	if (err < 0) {
-                snd_korg1212_free(korg1212);
-                return err;
-        }
+	if (err < 0)
+		goto free_sound_chip;
         
 	snd_korg1212_EnableCardInterrupts(korg1212);
 
@@ -2429,6 +2421,15 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
         * rchip = korg1212;
 	return 0;
 
+disable_device:
+	pci_disable_device(pci);
+	return err;
+
+e_nomem:
+	err = -ENOMEM;
+free_sound_chip:
+	snd_korg1212_free(korg1212);
+	return err;
 }
 
 /*
@@ -2457,10 +2458,8 @@ snd_korg1212_probe(struct pci_dev *pci,
 		return err;
 
 	err = snd_korg1212_create(card, pci, &korg1212);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
 
 	strcpy(card->driver, "korg1212");
 	strcpy(card->shortname, "korg1212");
@@ -2470,13 +2469,16 @@ snd_korg1212_probe(struct pci_dev *pci,
         K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname);
 
 	err = snd_card_register(card);
-	if (err < 0) {
-		snd_card_free(card);
-		return err;
-	}
+	if (err < 0)
+		goto free_card;
+
 	pci_set_drvdata(pci, card);
 	dev++;
 	return 0;
+
+free_card:
+	snd_card_free(card);
+	return err;
 }
 
 static void snd_korg1212_remove(struct pci_dev *pci)
-- 
2.15.0

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

* Re: [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_create()
  2017-11-16 11:52   ` [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_crea SF Markus Elfring
  (?)
@ 2017-11-28  7:31     ` Takashi Iwai
  -1 siblings, 0 replies; 15+ messages in thread
From: Takashi Iwai @ 2017-11-28  7:31 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Kees Cook, Alexey Dobriyan, Bhumika Goyal,
	Andrew Morton, Jaroslav Kysela, kernel-janitors, LKML

On Thu, 16 Nov 2017 12:52:41 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 16 Nov 2017 11:22:26 +0100
> 
> The function "release_firmware" is called in the current implementation of
> the function "_request_firmware" after a failure was detected.
> Link: https://elixir.free-electrons.com/linux/v4.14-rc8/source/drivers/base/firmware_class.c#L1196
> 
> Such a call should therefore not be repeated directly after the
> corresponding error information was received in the local variable "err"
> of the function "snd_korg1212_create".
> Thus remove a misplaced function call.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

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

* Re: [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_
@ 2017-11-28  7:31     ` Takashi Iwai
  0 siblings, 0 replies; 15+ messages in thread
From: Takashi Iwai @ 2017-11-28  7:31 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Kees Cook, Alexey Dobriyan, Bhumika Goyal,
	Andrew Morton, Jaroslav Kysela, kernel-janitors, LKML

On Thu, 16 Nov 2017 12:52:41 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 16 Nov 2017 11:22:26 +0100
> 
> The function "release_firmware" is called in the current implementation of
> the function "_request_firmware" after a failure was detected.
> Link: https://elixir.free-electrons.com/linux/v4.14-rc8/source/drivers/base/firmware_class.c#L1196
> 
> Such a call should therefore not be repeated directly after the
> corresponding error information was received in the local variable "err"
> of the function "snd_korg1212_create".
> Thus remove a misplaced function call.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

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

* Re: [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_create()
@ 2017-11-28  7:31     ` Takashi Iwai
  0 siblings, 0 replies; 15+ messages in thread
From: Takashi Iwai @ 2017-11-28  7:31 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Kees Cook, Alexey Dobriyan, Bhumika Goyal,
	Andrew Morton, Jaroslav Kysela, kernel-janitors, LKML

On Thu, 16 Nov 2017 12:52:41 +0100,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 16 Nov 2017 11:22:26 +0100
> 
> The function "release_firmware" is called in the current implementation of
> the function "_request_firmware" after a failure was detected.
> Link: https://elixir.free-electrons.com/linux/v4.14-rc8/source/drivers/base/firmware_class.c#L1196
> 
> Such a call should therefore not be repeated directly after the
> corresponding error information was received in the local variable "err"
> of the function "snd_korg1212_create".
> Thus remove a misplaced function call.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

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

end of thread, other threads:[~2017-11-28  7:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-16 11:50 [PATCH 0/3] ALSA: korg1212: Fine-tuning for three function implementations SF Markus Elfring
2017-11-16 11:50 ` SF Markus Elfring
2017-11-16 11:50 ` SF Markus Elfring
2017-11-16 11:51 ` [PATCH 1/3] ALSA: korg1212: Adjust eight function calls together with a variable assignment SF Markus Elfring
2017-11-16 11:51   ` SF Markus Elfring
2017-11-16 11:51   ` SF Markus Elfring
2017-11-16 11:52 ` [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_create() SF Markus Elfring
2017-11-16 11:52   ` SF Markus Elfring
2017-11-16 11:52   ` [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_crea SF Markus Elfring
2017-11-28  7:31   ` [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_create() Takashi Iwai
2017-11-28  7:31     ` Takashi Iwai
2017-11-28  7:31     ` [PATCH 2/3] ALSA: korg1212: Delete a duplicate function call "release_firmware" in snd_korg1212_ Takashi Iwai
2017-11-16 11:53 ` [PATCH 3/3] ALSA: korg1212: Use common error handling code in two functions SF Markus Elfring
2017-11-16 11:53   ` SF Markus Elfring
2017-11-16 11:53   ` SF Markus Elfring

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.