Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp2414390lfu; Fri, 25 Mar 2022 00:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAcNqfaVfbL2fdF7c65DW+2YjWBKwXVqF57JCRZestyQbDU/iOyeVLWjReAZv243bs2YAq X-Received: by 2002:a05:6402:2318:b0:413:7645:fa51 with SMTP id l24-20020a056402231800b004137645fa51mr11498146eda.201.1648192411525; Fri, 25 Mar 2022 00:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648192411; cv=none; d=google.com; s=arc-20160816; b=rqJynzuKoh/zeyn4a6KD4TnPdQxShgrOw1xmgHCsphPwyeG8GC7P8sl6JCtMZai3iA eiKsv6weXlrgHu+D+ta5BZhVxQjJYuk5yl854fwhOl1xMsmBmAPuktlMIVkaNo/s7eRw RuOgkIozc7SqGs2ZlepfVohhSrWBDdsoGuI/hwrdFkQVJg+xsOmdh/eEgX6ZMdWY8kjc /u52/mZVenYJQ8iW0yvwUOsQHMyoNCXcUTjh49Y+BVQ54VlscUtSMfRJcMwC1MiWqrrR FxEvTEiGpU9PqfmvnOXUKA3QocI09zFls3JibXQvOVz6sQSCuuU9vjVZwCw3G5YbocyR mSuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=k0bAzjh+AUgR2IJ351C39W3KAJR0vQBnMG0macu+KLY=; b=nF/X3UuxMy66oYQ3v+NcQguxYCKR4O5WzIsl6MyQIO8V4/BwO5h1wS4Z3hGEHhxVbF zmFnjdJ9YED9P55L+iRXbWA3I41ZLYGlAfZIbY3p6In+cnVTzUFKzNY1UKTnyG7sy+pr Y50snedlc/iORRRhoGdmYJfZ9ABurWuqaFoJvpg2VVL1otKntK6PFrgsRBT3jg/YrmWp FfA7/keRiyrrS7I3Sc+z3OXbay6xpuZBgak28TucTJ3oRw5e5noIfj8VMzouzZJThcYb PgEkZk5dVeeShq3r+kH79ugr+4erwaDDcGXZ4ZOQLdXn+BNS+qa4ARGuUYtY4k+8UTww Y7dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=JYWaoNl5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020aa7c1d3000000b00418c2b5bf3asi1687079edp.540.2022.03.25.00.12.46; Fri, 25 Mar 2022 00:13:31 -0700 (PDT) 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; dkim=pass header.i=@163.com header.s=s110527 header.b=JYWaoNl5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347238AbiCXIBV (ORCPT + 99 others); Thu, 24 Mar 2022 04:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240437AbiCXIBU (ORCPT ); Thu, 24 Mar 2022 04:01:20 -0400 X-Greylist: delayed 920 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 24 Mar 2022 00:59:48 PDT Received: from m12-18.163.com (m12-18.163.com [220.181.12.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9D69222B13 for ; Thu, 24 Mar 2022 00:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=k0bAzjh+AUgR2IJ351 C39W3KAJR0vQBnMG0macu+KLY=; b=JYWaoNl5be+C9Eh5neBJnZ6Sf+r6Ra8JsO av/zNx06JF18RRL7ek9J3rBWVyWjcD+DKbEVMpwj73SRJW2KlddA7XdtLtaj33Ki gG0RUaW+rGhQjncmDkmAKqoOmaxZB5OpoSrTgUmaZDcYG5yOnwqRFvQsDaG3+gmy ib/gDJbe8= Received: from localhost (unknown [159.226.95.33]) by smtp14 (Coremail) with SMTP id EsCowADXTotHITxi+cJzBg--.47842S2; Thu, 24 Mar 2022 15:44:08 +0800 (CST) From: QintaoShen To: kristo@kernel.org Cc: ssantosh@kernel.org, nm@ti.com, linux-kernel@vger.kernel.org, QintaoShen Subject: [PATCH v1] soc: ti: ti_sci_pm_domains: Check for null return of devm_kcalloc Date: Thu, 24 Mar 2022 15:44:03 +0800 Message-Id: <1648107843-29077-1-git-send-email-unSimple1993@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: EsCowADXTotHITxi+cJzBg--.47842S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrZw18WF1rWw4kCr17Cry7trb_yoWftrc_Cw 4UXrW3Gr45Cr93Kw1qkw43ZryY93Z8ZrnY9w1rt3sxXryUWw1rGF4UZFn3CanxW3yDGFnr Jan0vr13ArnxWjkaLaAFLSUrUUUUbb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRACzZJUUUUU== X-Originating-IP: [159.226.95.33] X-CM-SenderInfo: 5xqvxz5sohimizt6il2tof0z/1tbiNAjNH1aD-Km6YQAAs1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 --- 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 8afb3f45..a33ec7e 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.7.4