Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2159772iof; Tue, 7 Jun 2022 21:44:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxexC4Y9hslo1sDyCwG7yYosL7HTvt3G6bp9ZnXHEZWK0VHuB+C8itZS5Po3NzoNfOAm2PU X-Received: by 2002:a17:90b:464b:b0:1e8:7881:b238 with SMTP id jw11-20020a17090b464b00b001e87881b238mr16807344pjb.166.1654663498322; Tue, 07 Jun 2022 21:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663498; cv=none; d=google.com; s=arc-20160816; b=mwCFvgLHxTtpOTqpNPvkzUXC7533VM7zNOvihZKv4Z7lW/12MbAexU7H/7nApNcTku EuqajqVCCrPyDYjn0K1TmaakblPcAtZh6ZkgsyeRicZGx1BVAatpehHgXdIqg/SsK44u AyGQklD37xJhExWsqPuZz4LRxFqgec/4w93cMrM+suwCV64hjrsv3WAeuU60D0cRX0M/ ExQELtl/PCYPeS8bGemvgB10Vrb6CXHWFt+K02hGTZ8KkwmL1oAQQBRxcYBVANiifdNZ j6jBGsMha1rSAWSoIVdbU9+mhnd+XHa11FutN704AeXDg+mga7c3wOPEDlALIdhpOuB2 Fxcw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k9WYk+EXj2S2CTI3alFIj9gVMrWZtiy2wvff1w5qa0w=; b=KQSkIFQXw+pnOLfpf+O77Ph8yr9lI4zpaW60BkmmNRWV0NjSVvOj7rGpzOo9zD4zfR Q4hDBIS2KpXDH4mRC3E402DF+uddTBTwPfXJZWQNUQTERjaolG1Ug87Qwz3/TZwcYs0W ZicrmJzC3ugaCU9oWolSu11H/cig8ZX9jVa1BX1ee8nx5mrfvSMW6b0phVmtCOFL/xNR 7FWJCK2PcVEXZB2tvGPAddBM6X/RUV+aI+qenjQkeLV0va8ufGvxZOqjURlkZM/7b8qQ Ohmo89Ybv4mrNKJ5BQR9bA9KjBNKaclXYLQi3uvbyelSaArUKOqm8EoAy56CqMP4afuF USvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p3OfFsOA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v1-20020a62a501000000b0051b9771d617si24513313pfm.179.2022.06.07.21.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:44:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p3OfFsOA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9C0B6459E42; Tue, 7 Jun 2022 21:23:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385423AbiFGWVi (ORCPT + 99 others); Tue, 7 Jun 2022 18:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380625AbiFGVQh (ORCPT ); Tue, 7 Jun 2022 17:16:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC99821E32D; Tue, 7 Jun 2022 11:55:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 66958B81F6D; Tue, 7 Jun 2022 18:55:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA99EC385A2; Tue, 7 Jun 2022 18:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628138; bh=85vm1vrtGgzFH8G8lTONTiZh58r6Wicm/naQSPQ/3OI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p3OfFsOAT82Ju5wR/4ATJojAR6NEYDy0q6c03He3kwh3td53y92cVaaxpNlz7FiI6 7OCNNOvjDzBPNIiGDNqeh636ZdwPhPRmZBqNGPHyNkki6ogeMwR7OY47SearRHGWOs hzWcoaTmSHL+jNAxV/gxomEy5N9CQHaGxfwDZKuc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, QintaoShen , Nishanth Menon , Sasha Levin Subject: [PATCH 5.18 220/879] soc: ti: ti_sci_pm_domains: Check for null return of devm_kcalloc Date: Tue, 7 Jun 2022 18:55:38 +0200 Message-Id: <20220607165009.239976171@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: QintaoShen [ Upstream commit ba56291e297d28aa6eb82c5c1964fae2d7594746 ] The allocation funciton devm_kcalloc may fail and return a null pointer, which would cause a null-pointer dereference later. It might be better to check it and directly return -ENOMEM just like the usage of devm_kcalloc in previous code. Signed-off-by: QintaoShen Signed-off-by: Nishanth Menon Link: https://lore.kernel.org/r/1648107843-29077-1-git-send-email-unSimple1993@163.com Signed-off-by: Sasha Levin --- drivers/soc/ti/ti_sci_pm_domains.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/soc/ti/ti_sci_pm_domains.c b/drivers/soc/ti/ti_sci_pm_domains.c index 8afb3f45d263..a33ec7eaf23d 100644 --- a/drivers/soc/ti/ti_sci_pm_domains.c +++ b/drivers/soc/ti/ti_sci_pm_domains.c @@ -183,6 +183,8 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev) devm_kcalloc(dev, max_id + 1, sizeof(*pd_provider->data.domains), GFP_KERNEL); + if (!pd_provider->data.domains) + return -ENOMEM; pd_provider->data.num_domains = max_id + 1; pd_provider->data.xlate = ti_sci_pd_xlate; -- 2.35.1