summaryrefslogtreecommitdiffstats
path: root/sound/isa
diff options
context:
space:
mode:
authorXiaoke Wang <xkernel.wang@foxmail.com>2021-12-13 18:52:32 +0800
committerTakashi Iwai <tiwai@suse.de>2021-12-13 13:57:15 +0100
commit78977fd5b11cc90668c0dec6109d2f6572c9601c (patch)
treee084b43ad75778a3148d946c9206496c82994851 /sound/isa
parent55b71f6c29f2a78af42dd453dfed895eba516cb4 (diff)
downloadlinux-78977fd5b11cc90668c0dec6109d2f6572c9601c.tar.bz2
ALSA: sound/isa/gus: check the return value of kstrdup()
kstrdup() returns NULL when some internal memory errors happen, it is better to check the return value of it. Otherwise, we may not to be able to catch some memory errors in time. Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com> Link: https://lore.kernel.org/r/tencent_1E3950293AC22395ACFE99404C985D738309@qq.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/isa')
-rw-r--r--sound/isa/gus/gus_mem.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c
index ff9480f249fe..4c691dbf2721 100644
--- a/sound/isa/gus/gus_mem.c
+++ b/sound/isa/gus/gus_mem.c
@@ -199,6 +199,10 @@ struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owne
memcpy(&block.share_id, share_id, sizeof(block.share_id));
block.owner = owner;
block.name = kstrdup(name, GFP_KERNEL);
+ if (block.name == NULL) {
+ snd_gf1_mem_lock(alloc, 1);
+ return NULL;
+ }
nblock = snd_gf1_mem_xalloc(alloc, &block);
snd_gf1_mem_lock(alloc, 1);
return nblock;
@@ -237,13 +241,13 @@ int snd_gf1_mem_init(struct snd_gus_card * gus)
block.ptr = 0;
block.size = 1024;
block.name = kstrdup("InterWave LFOs", GFP_KERNEL);
- if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
+ if (block.name == NULL || snd_gf1_mem_xalloc(alloc, &block) == NULL)
return -ENOMEM;
}
block.ptr = gus->gf1.default_voice_address;
block.size = 4;
block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL);
- if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
+ if (block.name == NULL || snd_gf1_mem_xalloc(alloc, &block) == NULL)
return -ENOMEM;
#ifdef CONFIG_SND_DEBUG
snd_card_ro_proc_new(gus->card, "gusmem", gus, snd_gf1_mem_info_read);