Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp328034rwb; Wed, 16 Nov 2022 00:55:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf65QS5VB6Ae9kBJDzvWh+CUIpKwkFgYrEe1JuuxUTcDnWnmyUds3AUzllzcbT+CXbK9GDpv X-Received: by 2002:a63:ee02:0:b0:470:8f8b:c9e0 with SMTP id e2-20020a63ee02000000b004708f8bc9e0mr19544906pgi.390.1668588931591; Wed, 16 Nov 2022 00:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668588931; cv=none; d=google.com; s=arc-20160816; b=WNUa/xMOxm7vfUhHE1IWOOwxWXAqUNcGQtTIGgIg/8AY5bWOphQeNnad4rkFiJuKjL 5Dyh1c9tYM6Ojjz1AJoe1kslnFVt1iqEf+EGvkFTvMUqvAiUYRQ4NGjAlWTLkcD8yN+s RSjClP8Rc582N2VsUjiLx0/SuQDD5v98hPsIrJvHHLRE60cmot7TaZU/9f/ay2y7R6E9 otozJcvOtWUZRnH22ffbRqKdPJE8BPNG1MCisRiXdIL1boyCkYfp9hBXZwWzP9coW3bY sg4QIGRC+gKMXoWISiBPzP1LngG1p346020OWeTtB8i2Jtn+WdLY2FUqrYU+DR9zS9QU tbSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=8oxoQ3JA/2Fhsh3nMlecXNq3MDhzqND57goLje9Swgc=; b=TAxI6+msyshUxAE8p7StkLz6usjZw1dcaEse8kzUn+xf7kO7bg5RDj+jDILZjJ4w+4 UtMUr0QkUyC4numZHklfbRkVU0x0QGMhK60vega3uQGseDfBhhPEhPhCdsZ1Hd4teAcQ 4rpAYTiyszWc69COyTJ3m6nNh66sfpU/FT7+8t7DhAWdNEEGUVAW2aWydVpUmm726Hao lVd/mCVu5Tg0ku63HsYn7ZdhiDwvjm0/w4iTbx4ELOAkKJlpg2kqDj3fvCI1jLS6DFuO ZhH7P3941SLgqBxb8bUke0O6AdetLbnlFgbbOAe3bxbaJ5WXXJHJnc2Y4QkFwfj3ffz2 tNBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v69-20020a638948000000b0046ecd36adbasi13867902pgd.635.2022.11.16.00.55.20; Wed, 16 Nov 2022 00:55:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238884AbiKPI2T (ORCPT + 90 others); Wed, 16 Nov 2022 03:28:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239017AbiKPI1T (ORCPT ); Wed, 16 Nov 2022 03:27:19 -0500 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D57A827FDD for ; Wed, 16 Nov 2022 00:25:22 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-01 (Coremail) with SMTP id qwCowADnh2llnnRjqSwDCg--.35350S2; Wed, 16 Nov 2022 16:25:09 +0800 (CST) From: Jiasheng Jiang To: lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, ryan.lee.analog@gmail.com, steve@sk2.org, pierre-louis.bossart@linux.intel.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] ASoC: max98373: Add checks for devm_kcalloc Date: Wed, 16 Nov 2022 16:25:08 +0800 Message-Id: <20221116082508.17418-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: qwCowADnh2llnnRjqSwDCg--.35350S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Jw4kuF4fCF18Ww1fJFWkZwb_yoWfKrg_Za y8u3s8XrWUWFZ3ur45JrWYkFW8Wa42yrW2gr1qqry7GrWxGF13Jw4rJrn3Cw47ZFWkKF17 Wan2yrW7uw1q9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbV8FF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkIecxEwVAFwVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x0JUP-B_UUUUU= X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 3e04c7f0cce4..ec0905df65d1 100644 --- a/sound/soc/codecs/max98373-i2c.c +++ b/sound/soc/codecs/max98373-i2c.c @@ -549,6 +549,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.25.1