OSDN Git Service

ALSA: gus: Fix memory leaks at memory allocator error paths
authorTakashi Iwai <tiwai@suse.de>
Mon, 13 Dec 2021 14:15:12 +0000 (15:15 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 13 Dec 2021 15:41:12 +0000 (16:41 +0100)
commitdec242b6a8380c08e41e02fb54f1282894fb45cc
tree31cf4bc8b56b729fad49c9d4d3a4394d2379ce00
parentc2f51415401cb8e9b7991e828ae12ab2972f2ca7
ALSA: gus: Fix memory leaks at memory allocator error paths

When snd_gf1_mem_xalloc() returns NULL, the current code still leaves
the formerly allocated block.name string but returns an error
immediately.  This patch does code-refactoring to move the kstrdup()
call itself into snd_gf1_mem_xalloc() and deals with the resource free
in the helper code by itself for fixing those memory leaks.

Suggested-by: Jaroslav Kysela <perex@perex.cz>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20211213132444.22385-2-tiwai@suse.de
Link: https://lore.kernel.org/r/20211213141512.27359-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/isa/gus/gus_mem.c