Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp486961pxb; Mon, 8 Nov 2021 17:10:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJ9Vqz1beyRFv/8gzsLH0x6As9+ysaiSK1STg3Eaz7ly6HLBYEBEY3QrZYTh2kgTDG+HyP X-Received: by 2002:a17:907:97d0:: with SMTP id js16mr4416080ejc.199.1636420254407; Mon, 08 Nov 2021 17:10:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636420254; cv=none; d=google.com; s=arc-20160816; b=DVb1cIL0TBpPgi+efdiDg/H2cPf714qKmFj3k6bonTwwY0KipzoDESArYAP3lO9cmD 9TFl/3+IgeSNpyrpemLU9NPBZlbmBHAxTNh1/Ouj8IMlHDD0n4WsqK6Wij8jFAcDRim7 DxxVw8t0n+EckqlGodc86uoWuxfSxYSt4v0+LSylDbVRA7Vi6uM3KcRycS1nIJ0DK8dL y0jvpoPWHR/wj0VfgWWeK2NzTx/XYeHRBhBorSiDskQza3MuAjwmLiWMWL+iENarq6+r I+b23biEY1Bd11WwNRxOuhKDx8QDgkMdXis0c+a3cxp8JjAHxXl4U95oTxAuXJsmH0Rf spVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=n2y5uM6W39UUewevKc2q7vpt51dJGo4Ea4brCbFJv0w=; b=lsciamyaYdp0SEch/UU+BTTI89pO8EA7qtFG2h5lWWvTv6y/WYL+LznGslT27xZxis CQ0+tYdj4f74ScAiGtxl+jStfBF4M0sqljGspwVjB9FGSioUvIK0NMdSGPXTjMHSf5RJ g6QfSrkOBUf3oqG1xkNC0e5ob5Vf+EiY4y473sGVvRf7OpXsyD9PVUUFhzqxVXNZBoPq 74emHrk60HHF0wyo9RUcP9Vqt6nx2OEv4rRzuKkQeiUO1rQARugOGF2k8QS3vcOprwjU xmcEi8fCfZJVvEtrvc6mewqPDlaW50RcN+yesZlooM/3uoQP+KxEj3dg1Cl9cGRZtYGY 9duw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=osLlh7wM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si33131239eda.402.2021.11.08.17.10.25; Mon, 08 Nov 2021 17:10:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=osLlh7wM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241253AbhKIAkc (ORCPT + 99 others); Mon, 8 Nov 2021 19:40:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbhKIAkc (ORCPT ); Mon, 8 Nov 2021 19:40:32 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C56BC061570 for ; Mon, 8 Nov 2021 16:37:47 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id u11so17719769plf.3 for ; Mon, 08 Nov 2021 16:37:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=n2y5uM6W39UUewevKc2q7vpt51dJGo4Ea4brCbFJv0w=; b=osLlh7wMKgm3zPegAe8U7FuoEoPOCP3zbMR683xR04/0AndAYJl/fjTqoPMtuai56i P5aJyfAi9XpG5tjOpfoLaNFSa8N7xGbfQun6YIkOQBvIzthQajl4AU2iYpZorIYFAgxG 66u0ZJMmh6vE8hbrXFnf0GlYdrpcT/BV7z8Lsr+E7XaXhAdqOI3DpFJ2wxt49dB3dLEd 1K4Hg6pWVk8MIrceEZogSexwkFzGY+kKipbbTT5zz5CyzF622UUs6SO4nqFPOVqQwJMO n/xbFoh49gkB1XnarxC0UatSuyT1wKJd/O46ZTQElmFpIuFw3pnYOUSwaV7uOjeU0pDB 84wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=n2y5uM6W39UUewevKc2q7vpt51dJGo4Ea4brCbFJv0w=; b=GTTWBWQi6nuJQTScAhbjVSvJngTOSk3OltXa9rjsvnFblIDoaONrzJyyl7bJ+VhGkk NQ32PHwI/0XdFZFL7uJ8GV4NIhxXohSZGGTNcnNQp2rGKgd126n18/LSCDWETZe60LbL aixgwJ5K/KPp5vg/tORHQUU40Z1TC7mtfjmkAYow5YjM9+cMHTl/DFtvJUdmv4gF9CjN Aiy1Adu8JzSnvWY1F82jMtyLqv4YhTJtBUKlkm5btcDPBGuM8m0pX5Na8yEec5Qg3MqS ivKYjSlAaix8FeVPO+qcy2ZJfQq/p0cnxapj49b/2v/W0Xb5r3AK/KGmd0ExnBz9vbcK nyQQ== X-Gm-Message-State: AOAM5307k9WtYsvRoRjDTcA4zxxHfUUMs3MBi3JbtoXY5BJQt0FKWdlH Sx2+bEGvb8kdVRdCUXHzil5+Dr3gz+bzTQ== X-Received: by 2002:a17:902:bcc4:b0:141:bfc4:ada with SMTP id o4-20020a170902bcc400b00141bfc40adamr2990079pls.20.1636418266871; Mon, 08 Nov 2021 16:37:46 -0800 (PST) Received: from raspberrypi ([49.166.114.232]) by smtp.gmail.com with ESMTPSA id c9sm13308705pgq.58.2021.11.08.16.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 16:37:46 -0800 (PST) Date: Tue, 9 Nov 2021 00:37:42 +0000 From: Austin Kim To: tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, austin.kim@lge.com Subject: [PATCH] ALSA: missing check for possible NULL after the call to kstrdup Message-ID: <20211109003742.GA5423@raspberrypi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Austin Kim If kcalloc() return NULL due to memory starvation, it is possible for kstrdup() to return NULL in similar case. So add null check after the call to kstrdup() is made. Signed-off-by: Austin Kim --- sound/synth/emux/emux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index 49d1976a132c..6dab3c5bac00 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -88,7 +88,7 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch emu->name = kstrdup(name, GFP_KERNEL); emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice), GFP_KERNEL); - if (emu->voices == NULL) + if ((emu->name == NULL) || (emu->voices == NULL)) return -ENOMEM; /* create soundfont list */ -- 2.20.1