Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1710277 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-08-12 15:40 +0200 |
| Last post | 2017-08-12 23:30 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/3] ALSA: rme96: Adjustments for six function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-12 15:40 +0200
[PATCH 1/3] ALSA: rme96: Delete two error messages for a failed memory allocation in snd_rme96_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-12 15:50 +0200
[PATCH 2/3] ALSA: rme96: Use common error handling code in snd_rme96_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-12 15:50 +0200
[PATCH 3/3] ALSA: rme96: Adjust five checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2017-08-12 15:50 +0200
Re: [PATCH 0/3] ALSA: rme96: Adjustments for six function implementations Takashi Iwai <tiwai@suse.de> - 2017-08-12 23:30 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-08-12 15:40 +0200 |
| Subject | [PATCH 0/3] ALSA: rme96: Adjustments for six function implementations |
| Message-ID | <udENY-1ls-15@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> 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(-) -- 2.14.0
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-08-12 15:50 +0200 |
| Subject | [PATCH 1/3] ALSA: rme96: Delete two error messages for a failed memory allocation in snd_rme96_probe() |
| Message-ID | <udEXD-1pb-7@gated-at.bofh.it> |
| In reply to | #1710277 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/pci/rme96.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 2e19ba55e754..82e8c78e48ca 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -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;
}
--
2.14.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-08-12 15:50 +0200 |
| Subject | [PATCH 2/3] ALSA: rme96: Use common error handling code in snd_rme96_probe() |
| Message-ID | <udEXD-1pb-3@gated-at.bofh.it> |
| In reply to | #1710277 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/pci/rme96.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 82e8c78e48ca..0cdfd53b7796 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -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)
--
2.14.0
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-08-12 15:50 +0200 |
| Subject | [PATCH 3/3] ALSA: rme96: Adjust five checks for null pointers |
| Message-ID | <udEXD-1pb-9@gated-at.bofh.it> |
| In reply to | #1710277 |
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/pci/rme96.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 0cdfd53b7796..b488d74c3b99 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -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;
--
2.14.0
[toc] | [prev] | [next] | [standalone]
| From | Takashi Iwai <tiwai@suse.de> |
|---|---|
| Date | 2017-08-12 23:30 +0200 |
| Message-ID | <udM8O-6gz-5@gated-at.bofh.it> |
| In reply to | #1710277 |
On Sat, 12 Aug 2017 15:38:01 +0200, SF Markus Elfring wrote: > > From: Markus Elfring <elfring@users.sourceforge.net> > 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 Applied all three patches, thanks. Takashi
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web