Accepting request 179267 from home:tiwai:branches:multimedia:libs
- Backport upstream fixes for plug-in API rewind, a possible memory leak in direct plugins, chmap buffer overflow and some segfaults: 0003-Allow-specifying-the-max-number-of-cards.patch 0004-pcm_hw-Remove-unused-fields-in-struct.patch 0005-pcm_plugin-Fix-return-value-of-snd_pcm_rewind.patch 0006-pcm_direct-fix-the-memory-leak-when-parsing-the-slav.patch 0007-chmap-Always-succeed-setting-the-map-to-what-it-alre.patch 0008-pcm_hw-Fix-buffer-overflow-in-chmap.patch 0009-pcm_direct-fix-SEGFAULT-when-getgrnam_r-returns-0-an.patch OBS-URL: https://build.opensuse.org/request/show/179267 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=135
This commit is contained in:
parent
d7548a4249
commit
00857544be
116
0003-Allow-specifying-the-max-number-of-cards.patch
Normal file
116
0003-Allow-specifying-the-max-number-of-cards.patch
Normal file
@ -0,0 +1,116 @@
|
||||
From 2f43b66c06ece64529e482a6dcc95cde37648252 Mon Sep 17 00:00:00 2001
|
||||
From: Takashi Iwai <tiwai@suse.de>
|
||||
Date: Fri, 24 May 2013 17:21:15 +0200
|
||||
Subject: [PATCH] Allow specifying the max number of cards
|
||||
|
||||
Add --with-max-cards option to specify the max number of cards in
|
||||
configure script, when the support for more than 32 cards is
|
||||
required.
|
||||
|
||||
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
||||
---
|
||||
configure.in | 14 ++++++++++++++
|
||||
src/confmisc.c | 2 +-
|
||||
src/control/cards.c | 6 +++---
|
||||
src/control/control_hw.c | 2 +-
|
||||
src/hwdep/hwdep_hw.c | 2 +-
|
||||
5 files changed, 20 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/configure.in b/configure.in
|
||||
index 35b8e84..3d394fc 100644
|
||||
--- a/configure.in
|
||||
+++ b/configure.in
|
||||
@@ -632,6 +632,20 @@ for t in $CTL_PLUGIN_LIST; do
|
||||
fi
|
||||
done
|
||||
|
||||
+dnl Max number of cards
|
||||
+AC_MSG_CHECKING(for max number of cards)
|
||||
+AC_ARG_WITH(max-cards,
|
||||
+ AS_HELP_STRING([--with-max-cards], [Specify the max number of cards (default = 32)]),
|
||||
+ [ max_cards="$withval" ], [ max_cards="32" ])
|
||||
+AC_MSG_RESULT([$max_cards])
|
||||
+
|
||||
+if test "$max_cards" -lt 1; then
|
||||
+ AC_ERROR([Invalid max cards $max_cards])
|
||||
+elif test "$max_cards" -gt 256; then
|
||||
+ AC_ERROR([Invalid max cards $max_cards])
|
||||
+fi
|
||||
+AC_DEFINE_UNQUOTED(SND_MAX_CARDS, $max_cards, [Max number of cards])
|
||||
+
|
||||
dnl Make a symlink for inclusion of alsa/xxx.h
|
||||
if test ! -L "$srcdir"/include/alsa ; then
|
||||
echo "Making a symlink include/alsa"
|
||||
diff --git a/src/confmisc.c b/src/confmisc.c
|
||||
index 80b0027..af686be 100644
|
||||
--- a/src/confmisc.c
|
||||
+++ b/src/confmisc.c
|
||||
@@ -668,7 +668,7 @@ int snd_determine_driver(int card, char **driver)
|
||||
char *res = NULL;
|
||||
int err;
|
||||
|
||||
- assert(card >= 0 && card <= 32);
|
||||
+ assert(card >= 0 && card <= SND_MAX_CARDS);
|
||||
err = open_ctl(card, &ctl);
|
||||
if (err < 0) {
|
||||
SNDERR("could not open control for card %i", card);
|
||||
diff --git a/src/control/cards.c b/src/control/cards.c
|
||||
index b528e33..5d7376c 100644
|
||||
--- a/src/control/cards.c
|
||||
+++ b/src/control/cards.c
|
||||
@@ -103,7 +103,7 @@ int snd_card_next(int *rcard)
|
||||
return -EINVAL;
|
||||
card = *rcard;
|
||||
card = card < 0 ? 0 : card + 1;
|
||||
- for (; card < 32; card++) {
|
||||
+ for (; card < SND_MAX_CARDS; card++) {
|
||||
if (snd_card_load(card)) {
|
||||
*rcard = card;
|
||||
return 0;
|
||||
@@ -134,7 +134,7 @@ int snd_card_get_index(const char *string)
|
||||
(isdigit(*string) && isdigit(*(string + 1)) && *(string + 2) == 0)) {
|
||||
if (sscanf(string, "%i", &card) != 1)
|
||||
return -EINVAL;
|
||||
- if (card < 0 || card > 31)
|
||||
+ if (card < 0 || card >= SND_MAX_CARDS)
|
||||
return -EINVAL;
|
||||
err = snd_card_load1(card);
|
||||
if (err >= 0)
|
||||
@@ -143,7 +143,7 @@ int snd_card_get_index(const char *string)
|
||||
}
|
||||
if (string[0] == '/') /* device name */
|
||||
return snd_card_load2(string);
|
||||
- for (card = 0; card < 32; card++) {
|
||||
+ for (card = 0; card < SND_MAX_CARDS; card++) {
|
||||
#ifdef SUPPORT_ALOAD
|
||||
if (! snd_card_load(card))
|
||||
continue;
|
||||
diff --git a/src/control/control_hw.c b/src/control/control_hw.c
|
||||
index 90c4ba7..148097f 100644
|
||||
--- a/src/control/control_hw.c
|
||||
+++ b/src/control/control_hw.c
|
||||
@@ -382,7 +382,7 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
|
||||
|
||||
*handle = NULL;
|
||||
|
||||
- if (CHECK_SANITY(card < 0 || card >= 32)) {
|
||||
+ if (CHECK_SANITY(card < 0 || card >= SND_MAX_CARDS)) {
|
||||
SNDMSG("Invalid card index %d", card);
|
||||
return -EINVAL;
|
||||
}
|
||||
diff --git a/src/hwdep/hwdep_hw.c b/src/hwdep/hwdep_hw.c
|
||||
index e4fcdc3..4314e32 100644
|
||||
--- a/src/hwdep/hwdep_hw.c
|
||||
+++ b/src/hwdep/hwdep_hw.c
|
||||
@@ -112,7 +112,7 @@ int snd_hwdep_hw_open(snd_hwdep_t **handle, const char *name, int card, int devi
|
||||
|
||||
*handle = NULL;
|
||||
|
||||
- if (card < 0 || card >= 32)
|
||||
+ if (card < 0 || card >= SND_MAX_CARDS)
|
||||
return -EINVAL;
|
||||
sprintf(filename, SNDRV_FILE_HWDEP, card, device);
|
||||
fd = snd_open_device(filename, mode);
|
||||
--
|
||||
1.8.3
|
||||
|
30
0004-pcm_hw-Remove-unused-fields-in-struct.patch
Normal file
30
0004-pcm_hw-Remove-unused-fields-in-struct.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From 7f877543a36efd8fd5d38fae21352fc0567ece21 Mon Sep 17 00:00:00 2001
|
||||
From: David Henningsson <david.henningsson@canonical.com>
|
||||
Date: Thu, 30 May 2013 12:26:33 +0200
|
||||
Subject: [PATCH] pcm_hw: Remove unused fields in struct
|
||||
|
||||
These fields are not used, and their name similarity to other
|
||||
fields are quite confusing when trying to debug alsa-lib.
|
||||
|
||||
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
|
||||
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
||||
---
|
||||
src/pcm/pcm_hw.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
|
||||
index 0f3226d..196393d 100644
|
||||
--- a/src/pcm/pcm_hw.c
|
||||
+++ b/src/pcm/pcm_hw.c
|
||||
@@ -95,8 +95,6 @@ typedef struct {
|
||||
volatile struct snd_pcm_mmap_status * mmap_status;
|
||||
struct snd_pcm_mmap_control *mmap_control;
|
||||
struct snd_pcm_sync_ptr *sync_ptr;
|
||||
- snd_pcm_uframes_t hw_ptr;
|
||||
- snd_pcm_uframes_t appl_ptr;
|
||||
int period_event;
|
||||
snd_timer_t *period_timer;
|
||||
struct pollfd period_timer_pfd;
|
||||
--
|
||||
1.8.3
|
||||
|
40
0005-pcm_plugin-Fix-return-value-of-snd_pcm_rewind.patch
Normal file
40
0005-pcm_plugin-Fix-return-value-of-snd_pcm_rewind.patch
Normal file
@ -0,0 +1,40 @@
|
||||
From f2d39afe6139ab16aa2aeea0f51f32db79ab1262 Mon Sep 17 00:00:00 2001
|
||||
From: David Henningsson <david.henningsson@canonical.com>
|
||||
Date: Thu, 30 May 2013 12:26:34 +0200
|
||||
Subject: [PATCH] pcm_plugin: Fix return value of snd_pcm_rewind
|
||||
|
||||
In case the rewind did not rewind as much as expected, e g due to
|
||||
time delay between the latest avail update and the rewind, we must
|
||||
properly account for that in the plugin layer.
|
||||
|
||||
Otherwise, the plugin's appl ptr and the hw's appl ptr become
|
||||
unsynchronised, which is very bad, especially in mmap_shadow plugins,
|
||||
e g, this could cause the overlapping memcpy in the softvol plugin
|
||||
as seen here:
|
||||
https://bugs.freedesktop.org/show_bug.cgi?id=64299
|
||||
|
||||
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
|
||||
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
||||
---
|
||||
src/pcm/pcm_plugin.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c
|
||||
index 96218a8..17157e8 100644
|
||||
--- a/src/pcm/pcm_plugin.c
|
||||
+++ b/src/pcm/pcm_plugin.c
|
||||
@@ -219,9 +219,9 @@ static snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t
|
||||
snd_atomic_write_end(&plugin->watom);
|
||||
return sframes;
|
||||
}
|
||||
- snd_pcm_mmap_appl_backward(pcm, (snd_pcm_uframes_t) frames);
|
||||
+ snd_pcm_mmap_appl_backward(pcm, (snd_pcm_uframes_t) sframes);
|
||||
snd_atomic_write_end(&plugin->watom);
|
||||
- return (snd_pcm_sframes_t) frames;
|
||||
+ return (snd_pcm_sframes_t) sframes;
|
||||
}
|
||||
|
||||
static snd_pcm_sframes_t snd_pcm_plugin_forwardable(snd_pcm_t *pcm)
|
||||
--
|
||||
1.8.3
|
||||
|
@ -0,0 +1,65 @@
|
||||
From ca487c9511c1500184023dfea803a5e785d725e2 Mon Sep 17 00:00:00 2001
|
||||
From: Jaroslav Kysela <perex@perex.cz>
|
||||
Date: Tue, 4 Jun 2013 15:58:34 +0200
|
||||
Subject: [PATCH] pcm_direct: fix the memory leak when parsing the slave
|
||||
definitions
|
||||
|
||||
Reported-by: <bolsunov@telum.ru>
|
||||
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
||||
---
|
||||
src/pcm/pcm_direct.c | 32 +++++++++++++++++++++++---------
|
||||
1 file changed, 23 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
|
||||
index 38c6c66..101d3c8 100644
|
||||
--- a/src/pcm/pcm_direct.c
|
||||
+++ b/src/pcm/pcm_direct.c
|
||||
@@ -1453,7 +1453,7 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root,
|
||||
int hop)
|
||||
{
|
||||
snd_config_iterator_t i, next;
|
||||
- snd_config_t *pcm_conf;
|
||||
+ snd_config_t *pcm_conf, *pcm_conf2;
|
||||
int err;
|
||||
long card = 0, device = 0, subdevice = 0;
|
||||
const char *str;
|
||||
@@ -1484,14 +1484,28 @@ static int _snd_pcm_direct_get_slave_ipc_offset(snd_config_t *root,
|
||||
}
|
||||
#endif
|
||||
|
||||
- if (snd_config_search(sconf, "slave", &pcm_conf) >= 0 &&
|
||||
- (snd_config_search(pcm_conf, "pcm", &pcm_conf) >= 0 ||
|
||||
- (snd_config_get_string(pcm_conf, &str) >= 0 &&
|
||||
- snd_config_search_definition(root, "pcm_slave", str, &pcm_conf) >= 0 &&
|
||||
- snd_config_search(pcm_conf, "pcm", &pcm_conf) >= 0)))
|
||||
- return _snd_pcm_direct_get_slave_ipc_offset(root, pcm_conf,
|
||||
- direction,
|
||||
- hop + 1);
|
||||
+ if (snd_config_search(sconf, "slave", &pcm_conf) >= 0) {
|
||||
+ if (snd_config_search(pcm_conf, "pcm", &pcm_conf) >= 0) {
|
||||
+ return _snd_pcm_direct_get_slave_ipc_offset(root,
|
||||
+ pcm_conf,
|
||||
+ direction,
|
||||
+ hop + 1);
|
||||
+ } else {
|
||||
+ if (snd_config_get_string(pcm_conf, &str) >= 0 &&
|
||||
+ snd_config_search_definition(root, "pcm_slave",
|
||||
+ str, &pcm_conf) >= 0) {
|
||||
+ if (snd_config_search(pcm_conf, "pcm",
|
||||
+ &pcm_conf2) >= 0) {
|
||||
+ err =
|
||||
+ _snd_pcm_direct_get_slave_ipc_offset(
|
||||
+ root, pcm_conf2, direction, hop + 1);
|
||||
+ snd_config_delete(pcm_conf);
|
||||
+ return err;
|
||||
+ }
|
||||
+ snd_config_delete(pcm_conf);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
snd_config_for_each(i, next, sconf) {
|
||||
snd_config_t *n = snd_config_iterator_entry(i);
|
||||
--
|
||||
1.8.3
|
||||
|
@ -0,0 +1,46 @@
|
||||
From d20e24e5d1614354e9c8195ed0b11fe089c489e4 Mon Sep 17 00:00:00 2001
|
||||
From: David Henningsson <david.henningsson@canonical.com>
|
||||
Date: Wed, 5 Jun 2013 16:52:10 +0200
|
||||
Subject: [PATCH] chmap: Always succeed setting the map to what it already is
|
||||
|
||||
If we try to set the channel map to what it already is, this should
|
||||
always succeed. E g, speaker-test can do this sometimes.
|
||||
|
||||
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
|
||||
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
||||
---
|
||||
src/pcm/pcm.c | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
|
||||
index 7ec1f0e..ca4d416 100644
|
||||
--- a/src/pcm/pcm.c
|
||||
+++ b/src/pcm/pcm.c
|
||||
@@ -7361,6 +7361,13 @@ OBSOLETE1(snd_pcm_sw_params_get_silence_size, ALSA_0.9, ALSA_0.9.0rc4);
|
||||
|
||||
#endif /* DOC_HIDDEN */
|
||||
|
||||
+static int chmap_equal(const snd_pcm_chmap_t *a, const snd_pcm_chmap_t *b)
|
||||
+{
|
||||
+ if (a->channels != b->channels)
|
||||
+ return 0;
|
||||
+ return !memcmp(a->pos, b->pos, a->channels * sizeof(a->pos[0]));
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* \!brief Query the available channel maps
|
||||
* \param pcm PCM handle to query
|
||||
@@ -7415,6 +7422,10 @@ snd_pcm_chmap_t *snd_pcm_get_chmap(snd_pcm_t *pcm)
|
||||
*/
|
||||
int snd_pcm_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map)
|
||||
{
|
||||
+ const snd_pcm_chmap_t *oldmap = snd_pcm_get_chmap(pcm);
|
||||
+ if (oldmap && chmap_equal(oldmap, map))
|
||||
+ return 0;
|
||||
+
|
||||
if (!pcm->ops->set_chmap)
|
||||
return -ENXIO;
|
||||
return pcm->ops->set_chmap(pcm, map);
|
||||
--
|
||||
1.8.3
|
||||
|
30
0008-pcm_hw-Fix-buffer-overflow-in-chmap.patch
Normal file
30
0008-pcm_hw-Fix-buffer-overflow-in-chmap.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From c91785e002b96afad344a8ab182e8d33e355b7f7 Mon Sep 17 00:00:00 2001
|
||||
From: David Henningsson <david.henningsson@canonical.com>
|
||||
Date: Mon, 10 Jun 2013 16:42:47 +0200
|
||||
Subject: [PATCH] pcm_hw: Fix buffer overflow in chmap
|
||||
|
||||
We can't calculate memory storage in bytes, when we're supposed
|
||||
to store ints in it!
|
||||
|
||||
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
|
||||
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
||||
---
|
||||
src/pcm/pcm_hw.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
|
||||
index 196393d..9ff83a9 100644
|
||||
--- a/src/pcm/pcm_hw.c
|
||||
+++ b/src/pcm/pcm_hw.c
|
||||
@@ -1187,7 +1187,7 @@ static snd_pcm_chmap_t *snd_pcm_hw_get_chmap(snd_pcm_t *pcm)
|
||||
snd_pcm_state_name(FAST_PCM_STATE(hw)));
|
||||
return NULL;
|
||||
}
|
||||
- map = malloc(pcm->channels + 1);
|
||||
+ map = malloc(pcm->channels * sizeof(map->pos[0]) + sizeof(*map));
|
||||
if (!map)
|
||||
return NULL;
|
||||
map->channels = pcm->channels;
|
||||
--
|
||||
1.8.3
|
||||
|
@ -0,0 +1,28 @@
|
||||
From 9d6736c9a2232ed105ebe38b3a2e21a98f5dd5ba Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= <khalasa@piap.pl>
|
||||
Date: Fri, 14 Jun 2013 13:59:38 +0200
|
||||
Subject: [PATCH] pcm_direct: fix SEGFAULT when getgrnam_r() returns 0 and pgrp
|
||||
is NULL
|
||||
|
||||
Signed-off-by: Krzysztof Halasa <khalasa@piap.pl>
|
||||
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
||||
---
|
||||
src/pcm/pcm_direct.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
|
||||
index 101d3c8..899c250 100644
|
||||
--- a/src/pcm/pcm_direct.c
|
||||
+++ b/src/pcm/pcm_direct.c
|
||||
@@ -1650,7 +1650,7 @@ int snd_pcm_direct_parse_open_conf(snd_config_t *root, snd_config_t *conf,
|
||||
if (buffer == NULL)
|
||||
return -ENOMEM;
|
||||
int st = getgrnam_r(group, &grp, buffer, len, &pgrp);
|
||||
- if (st != 0) {
|
||||
+ if (st != 0 || !pgrp) {
|
||||
SNDERR("The field ipc_gid must be a valid group (create group %s)", group);
|
||||
free(buffer);
|
||||
return -EINVAL;
|
||||
--
|
||||
1.8.3
|
||||
|
13
alsa.changes
13
alsa.changes
@ -1,3 +1,16 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Jun 17 10:10:44 CEST 2013 - tiwai@suse.de
|
||||
|
||||
- Backport upstream fixes for plug-in API rewind, a possible memory
|
||||
leak in direct plugins, chmap buffer overflow and some segfaults:
|
||||
0003-Allow-specifying-the-max-number-of-cards.patch
|
||||
0004-pcm_hw-Remove-unused-fields-in-struct.patch
|
||||
0005-pcm_plugin-Fix-return-value-of-snd_pcm_rewind.patch
|
||||
0006-pcm_direct-fix-the-memory-leak-when-parsing-the-slav.patch
|
||||
0007-chmap-Always-succeed-setting-the-map-to-what-it-alre.patch
|
||||
0008-pcm_hw-Fix-buffer-overflow-in-chmap.patch
|
||||
0009-pcm_direct-fix-SEGFAULT-when-getgrnam_r-returns-0-an.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu May 23 15:03:35 CEST 2013 - tiwai@suse.de
|
||||
|
||||
|
14
alsa.spec
14
alsa.spec
@ -56,6 +56,13 @@ Source41: install-snd-module
|
||||
# upstream fixes
|
||||
Patch1: 0001-pcm-Fix-typo-in-documentation-PREPARE-PREPARED.patch
|
||||
Patch2: 0002-ucm-Fix-segfault-when-device-argument-is-missing-fro.patch
|
||||
Patch3: 0003-Allow-specifying-the-max-number-of-cards.patch
|
||||
Patch4: 0004-pcm_hw-Remove-unused-fields-in-struct.patch
|
||||
Patch5: 0005-pcm_plugin-Fix-return-value-of-snd_pcm_rewind.patch
|
||||
Patch6: 0006-pcm_direct-fix-the-memory-leak-when-parsing-the-slav.patch
|
||||
Patch7: 0007-chmap-Always-succeed-setting-the-map-to-what-it-alre.patch
|
||||
Patch8: 0008-pcm_hw-Fix-buffer-overflow-in-chmap.patch
|
||||
Patch9: 0009-pcm_direct-fix-SEGFAULT-when-getgrnam_r-returns-0-an.patch
|
||||
# rest suse patches
|
||||
Patch99: alsa-lib-doxygen-avoid-crash-for-11.3.diff
|
||||
Url: http://www.alsa-project.org/
|
||||
@ -109,6 +116,13 @@ Architecture.
|
||||
# %patch -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
%patch7 -p1
|
||||
%patch8 -p1
|
||||
%patch9 -p1
|
||||
%if %suse_version == 1130
|
||||
%patch99 -p1
|
||||
%endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user