From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C08DC79C0 for ; Wed, 30 Nov 2022 18:35:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BE5FC433C1; Wed, 30 Nov 2022 18:35:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669833318; bh=ZAwl0ACzd3+G4lbTVx/VqBe3fLgAPj+hpodVWq+QNA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bb4GxVn4qAzTUVFv6X617snY2fKBm5UZIqzjb7IcxLatJ5mziltsyYly484HYNUK0 O+xBTKJrDFmaAMK6A0Sw9SYa8bMnsxoyDnvSx4zQ2rRfNJT0WN3TNoqy0u68tbpGub 3PlkmOM+EtmauXT7GmxSyiizw1BPBMYwuOwGjtg4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiasheng Jiang , Mark Brown , Sasha Levin Subject: [PATCH 5.15 064/206] ASoC: max98373: Add checks for devm_kcalloc Date: Wed, 30 Nov 2022 19:21:56 +0100 Message-Id: <20221130180534.627991536@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221130180532.974348590@linuxfoundation.org> References: <20221130180532.974348590@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jiasheng Jiang [ Upstream commit 60591bbf6d5eb44f275eb733943b7757325c1b60 ] As the devm_kcalloc may return NULL pointer, it should be better to check the return value in order to avoid NULL poineter dereference. Fixes: 349dd23931d1 ("ASoC: max98373: don't access volatile registers in bias level off") Signed-off-by: Jiasheng Jiang Link: https://lore.kernel.org/r/20221116082508.17418-1-jiasheng@iscas.ac.cn Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/max98373-i2c.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/codecs/max98373-i2c.c b/sound/soc/codecs/max98373-i2c.c index ddb6436835d7..68497a4521dd 100644 --- a/sound/soc/codecs/max98373-i2c.c +++ b/sound/soc/codecs/max98373-i2c.c @@ -551,6 +551,10 @@ static int max98373_i2c_probe(struct i2c_client *i2c, max98373->cache = devm_kcalloc(&i2c->dev, max98373->cache_num, sizeof(*max98373->cache), GFP_KERNEL); + if (!max98373->cache) { + ret = -ENOMEM; + return ret; + } for (i = 0; i < max98373->cache_num; i++) max98373->cache[i].reg = max98373_i2c_cache_reg[i]; -- 2.35.1