alsa/0011-pcm_hw-fix-possible-memory-leak-coverity.patch
Ismail Dönmez 98d999615a Accepting request 357797 from home:tiwai:branches:multimedia:libs
- Backports from upstream: minor PCM fixes, topology API updates,
  and a few build cleanup:
  0002-pcm-simple-Fix-asserts.patch
  0003-topology-open-topology-files-with-O_TRUNC.patch
  0004-topology-Remove-unused-function-write_data_block.patch
  0005-topology-Remove-unused-variables.patch
  0006-topology-Fix-comparison-of-unsigned-expression-0.patch
  0007-topology-Not-compare-a-for-loop-iterator-with-ABI-__.patch
  0008-topology-Quit-and-show-error-message-on-big-endian-m.patch
  0009-config-files-do-not-include-ucm-topology-configurati.patch
  0010-control-add-missing-asserts-to-ctl_elem_set-function.patch
  0011-pcm_hw-fix-possible-memory-leak-coverity.patch
  0012-coverity-fixes.patch
  0013-topology-fix-debug-output-to-print-correct-max-value.patch

OBS-URL: https://build.opensuse.org/request/show/357797
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=192
2016-02-05 07:31:48 +00:00

138 lines
3.6 KiB
Diff

From 0f4f48d37716be0e6ddccb2124c5e09d5bd1cab3 Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Tue, 12 Jan 2016 16:07:16 +0100
Subject: [PATCH] pcm_hw: fix possible memory leak (coverity)
---
src/pcm/pcm.c | 2 +-
src/pcm/pcm_hw.c | 36 ++++++++++++++++++++----------------
2 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index cbbc55ae6ec9..203e7a52491b 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -7512,7 +7512,7 @@ snd_pcm_chmap_query_t **snd_pcm_query_chmaps(snd_pcm_t *pcm)
*/
void snd_pcm_free_chmaps(snd_pcm_chmap_query_t **maps)
{
- snd_pcm_chmap_query_t **p = maps;
+ snd_pcm_chmap_query_t **p;
if (!maps)
return;
for (p = maps; *p; p++)
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 66aec5c615ed..4f4b84b2d2bc 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -1693,12 +1693,14 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_string(n, &str);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return -EINVAL;
+ err = -EINVAL;
+ goto fail;
}
card = snd_card_get_index(str);
if (card < 0) {
SNDERR("Invalid value for %s", id);
- return card;
+ err = card;
+ goto fail;
}
}
continue;
@@ -1707,7 +1709,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_integer(n, &device);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return err;
+ goto fail;
}
continue;
}
@@ -1715,7 +1717,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_integer(n, &subdevice);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return err;
+ goto fail;
}
continue;
}
@@ -1738,7 +1740,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return err;
+ goto fail;
}
rate = val;
continue;
@@ -1747,7 +1749,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_string(n, &str);
if (err < 0) {
SNDERR("invalid type for %s", id);
- return err;
+ goto fail;
}
format = snd_pcm_format_value(str);
continue;
@@ -1757,7 +1759,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
err = snd_config_get_integer(n, &val);
if (err < 0) {
SNDERR("Invalid type for %s", id);
- return err;
+ goto fail;
}
channels = val;
continue;
@@ -1767,26 +1769,24 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
chmap = _snd_pcm_parse_config_chmaps(n);
if (!chmap) {
SNDERR("Invalid channel map for %s", id);
- return -EINVAL;
+ goto fail;
}
continue;
}
SNDERR("Unknown field %s", id);
- snd_pcm_free_chmaps(chmap);
- return -EINVAL;
+ err = -EINVAL;
+ goto fail;
}
if (card < 0) {
SNDERR("card is not defined");
- snd_pcm_free_chmaps(chmap);
- return -EINVAL;
+ err = -EINVAL;
+ goto fail;
}
err = snd_pcm_hw_open(pcmp, name, card, device, subdevice, stream,
mode | (nonblock ? SND_PCM_NONBLOCK : 0),
0, sync_ptr_ioctl);
- if (err < 0) {
- snd_pcm_free_chmaps(chmap);
- return err;
- }
+ if (err < 0)
+ goto fail;
if (nonblock && ! (mode & SND_PCM_NONBLOCK)) {
/* revert to blocking mode for read/write access */
snd_pcm_hw_nonblock(*pcmp, 0);
@@ -1810,6 +1810,10 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
hw->chmap_override = chmap;
return 0;
+
+fail:
+ snd_pcm_free_chmaps(chmap);
+ return err;
}
#ifndef DOC_HIDDEN
--
2.7.0