ALSA: rme96: Adjustments for six function implementations
Subsystems (2)
cover ALSA: rme96: Adjustments for six function implementations
From: Markus Elfring <[email protected]>
Date: Sat, 12 Aug 2017 15:36:54 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete two error messages for a failed memory allocation in snd_rme96_probe() Use common error handling code in snd_rme96_probe()
Adjust five checks for null pointers
sound/pci/rme96.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-)
Signature · 1 line
2.14.0
PATCH 1/3 ALSA: rme96: Delete two error messages for a failed memory allocation in snd_rme96_probe()
From: Markus Elfring <[email protected]>
Date: Sat, 12 Aug 2017 14:24:41 +0200
Omit extra messages for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- sound/pci/rme96.c | 4 ---- 1 file changed, 4 deletions(-)
sound/pci/rme96.c +0 -4
@@ -2489,15 +2489,11 @@ snd_rme96_probe(struct pci_dev *pci,#ifdef CONFIG_PM_SLEEP rme96->playback_suspend_buffer =vmalloc (RME96_BUFFER_SIZE );if (!rme96->playback_suspend_buffer) { -dev_err (card->dev, -"Failed to allocate playback suspend buffer!\n" );snd_card_free (card);return -ENOMEM ; } rme96->capture_suspend_buffer =vmalloc (RME96_BUFFER_SIZE );if (!rme96->capture_suspend_buffer) { -dev_err (card->dev, -"Failed to allocate capture suspend buffer!\n" );snd_card_free (card);return -ENOMEM ; }
Signature · 1 line
2.14.0
PATCH 2/3 ALSA: rme96: Use common error handling code in snd_rme96_probe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 12 Aug 2017 14:50:33 +0200
Add a jump target so that a bit of exception handling can be better reused at the end of this function.
--- sound/pci/rme96.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
sound/pci/rme96.c +14 -13
@@ -2481,21 +2481,20 @@ snd_rme96_probe(struct pci_dev *pci, rme96 = card->private_data; rme96->card = card; rme96->pci = pci; -if ((err =snd_rme96_create (rme96)) <0 ) { -snd_card_free (card); -return err; - } + err =snd_rme96_create (rme96); +if (err) + goto free_card;#ifdef CONFIG_PM_SLEEP rme96->playback_suspend_buffer =vmalloc (RME96_BUFFER_SIZE );if (!rme96->playback_suspend_buffer) { -snd_card_free (card); -return -ENOMEM ; + err = -ENOMEM ; + goto free_card; } rme96->capture_suspend_buffer =vmalloc (RME96_BUFFER_SIZE );if (!rme96->capture_suspend_buffer) { -snd_card_free (card); -return -ENOMEM ; + err = -ENOMEM ; + goto free_card; }#endif
@@ -2521,14 +2520,16 @@ snd_rme96_probe(struct pci_dev *pci, }sprintf (card->longname,"%s at 0x%lx, irq %d" , card->shortname, rme96->port, rme96->irq); - -if ((err =snd_card_register (card)) <0 ) { -snd_card_free (card); -return err; - } + err =snd_card_register (card); +if (err) + goto free_card; +pci_set_drvdata (pci, card); dev++;return 0 ; +free_card: +snd_card_free (card); +return err; }static void snd_rme96_remove (struct pci_dev *pci)
Signature · 1 line
2.14.0
PATCH 3/3 ALSA: rme96: Adjust five checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 12 Aug 2017 15:18:56 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written …
Thus fix the affected source code places.
--- sound/pci/rme96.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/pci/rme96.c +6 -6
@@ -1199,7 +1199,7 @@ snd_rme96_playback_spdif_open(struct snd_pcm_substream *substream)snd_pcm_set_sync (substream);spin_lock_irq (&rme96->lock); -if (rme96->playback_substream !=NULL ) { +if (rme96->playback_substream) {spin_unlock_irq (&rme96->lock);return -EBUSY ; }
@@ -1248,7 +1248,7 @@ snd_rme96_capture_spdif_open(struct snd_pcm_substream *substream) }spin_lock_irq (&rme96->lock); -if (rme96->capture_substream !=NULL ) { +if (rme96->capture_substream) {spin_unlock_irq (&rme96->lock);return -EBUSY ; }
@@ -1268,7 +1268,7 @@ snd_rme96_playback_adat_open(struct snd_pcm_substream *substream)snd_pcm_set_sync (substream);spin_lock_irq (&rme96->lock); -if (rme96->playback_substream !=NULL ) { +if (rme96->playback_substream) {spin_unlock_irq (&rme96->lock);return -EBUSY ; }
@@ -1315,7 +1315,7 @@ snd_rme96_capture_adat_open(struct snd_pcm_substream *substream) }spin_lock_irq (&rme96->lock); -if (rme96->capture_substream !=NULL ) { +if (rme96->capture_substream) {spin_unlock_irq (&rme96->lock);return -EBUSY ; }
@@ -1578,9 +1578,9 @@ snd_rme96_free(void *private_data) {struct rme96 *rme96 = (struct rme96 *)private_data; -if (rme96 =NULL ) { +if (!rme96)return ; - } +if (rme96->irq >=0 ) {snd_rme96_trigger (rme96,RME96_STOP_BOTH ); rme96->areg &= ~RME96_AR_DAC_EN ;
Signature · 1 line
2.14.0
Takashi Iwai
AppliedQuoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 12 Aug 2017 15:36:54 +0200A few update suggestions were taken into account
from static source code analysis.Markus Elfring (3):
Delete two error messages for a failed memory allocation insnd_rme96_probe()Use common error handling code insnd_rme96_probe()
Adjust five checks for null pointers
Applied all three patches, thanks.
Takashi