From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5A61C4321E for ; Tue, 16 Nov 2021 01:43:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0C5C61C14 for ; Tue, 16 Nov 2021 01:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357507AbhKPBqC (ORCPT ); Mon, 15 Nov 2021 20:46:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:60616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241224AbhKOSUc (ORCPT ); Mon, 15 Nov 2021 13:20:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 169F96331F; Mon, 15 Nov 2021 17:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1636998739; bh=5Czvmy/Z7GfcashVrKRSNfkfkMxcmrh7/KppuZzOj7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmWQkBIjBYdRxSwhKMn9l+izs7x51eF0bfmEtwr3H8/ealwgtWUu99CV6ggH43waH myiDJvtp33iT6bJgtRtnKn85SQXwEWUznklYUhW6/jeAbnVT3S6dYFdxOiDjeXsSay cA33CGF8KK5q6yPtxGvttK08Mu+XDuBa+oGc2X08= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Austin Kim , Takashi Iwai Subject: [PATCH 5.14 044/849] ALSA: synth: missing check for possible NULL after the call to kstrdup Date: Mon, 15 Nov 2021 17:52:07 +0100 Message-Id: <20211115165421.489324666@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211115165419.961798833@linuxfoundation.org> References: <20211115165419.961798833@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Austin Kim commit d159037abbe3412285c271bdfb9cdf19e62678ff upstream. 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. [ minor coding-style fix by tiwai ] Signed-off-by: Austin Kim Cc: Link: https://lore.kernel.org/r/20211109003742.GA5423@raspberrypi Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/synth/emux/emux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -88,7 +88,7 @@ int snd_emux_register(struct snd_emux *e 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 */