mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
Do not abort in snd_xxx_close() functions
Remove several memory leaks by not aborting prematurely from a snd_xxx_close() function when some operation fails. This can happen when a USB device was unplugged.
This commit is contained in:
parent
f9c7321670
commit
45850439b3
11 changed files with 33 additions and 33 deletions
|
|
@ -55,13 +55,13 @@ static int snd_pcm_hooks_close(snd_pcm_t *pcm)
|
|||
snd_pcm_hooks_t *h = pcm->private_data;
|
||||
struct list_head *pos, *next;
|
||||
unsigned int k;
|
||||
int err;
|
||||
int res = 0, err;
|
||||
|
||||
list_for_each_safe(pos, next, &h->hooks[SND_PCM_HOOK_TYPE_CLOSE]) {
|
||||
snd_pcm_hook_t *hook = list_entry(pos, snd_pcm_hook_t, list);
|
||||
err = hook->func(hook);
|
||||
if (err < 0)
|
||||
return err;
|
||||
res = err;
|
||||
}
|
||||
for (k = 0; k <= SND_PCM_HOOK_TYPE_LAST; ++k) {
|
||||
struct list_head *hooks = &h->hooks[k];
|
||||
|
|
@ -72,7 +72,10 @@ static int snd_pcm_hooks_close(snd_pcm_t *pcm)
|
|||
snd_pcm_hook_remove(hook);
|
||||
}
|
||||
}
|
||||
return snd_pcm_generic_close(pcm);
|
||||
err = snd_pcm_generic_close(pcm);
|
||||
if (err < 0)
|
||||
res = err;
|
||||
return res;
|
||||
}
|
||||
|
||||
static int snd_pcm_hooks_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue