Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp848688pxb; Wed, 6 Apr 2022 01:50:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSG7I5sJjKgyYC9N1QgDQWqV/RKFt6fmIPBJJJP5qqLmsszN3+BhDnZnZCFauPPSOV2FV6 X-Received: by 2002:a05:6a00:234f:b0:4f6:f0c0:ec68 with SMTP id j15-20020a056a00234f00b004f6f0c0ec68mr7892004pfj.14.1649235034930; Wed, 06 Apr 2022 01:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649235034; cv=none; d=google.com; s=arc-20160816; b=EAnNRUVS/k7VkbS7vyzFJ+tfT4Ehps/nP72QyYw9Ss2KdNRhztTI4OvWELoLfjxgLb 5bwQ5L5+2Gx4AU8H0uN6NpbS0yDco29tqe/asFqi/ma7zmynpZlUgmIpQZ8sk6+C1u2e Oelsa8/7z2jLrIO9A3dqlY+jm1g41Mrx3tMF5TMIB+R+A/O2w2QWVgIQvhMdqRHkiRSu 4AY5v9IygxHSLlCieO36ulezeaC8iJSNzW2IJZf44TXyqBz8pryFuBb9GOy+gVicINZU 5IPM7V53u11bBaiMgRVqfXScU4jriy9gpcoo/F7m5mCaQ0uMz41Qo9n6zMDEtAUoJFy0 TGNw== 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=8eys6RN9PODet77RCM5ylHHGcgLcVaODfST64KwSx/A=; b=yTVl74xP7M8pYb6BdpXCxl5KEUAYGa/iZh0tp8kvSxGP3aRUQxOyGZ2slz3S1fn+Co hdoxGq/lsZv3G3UFxUHpJNgTuURdyqwC1wCvM6BwkFmLukN0Zj98gb456dEMEdXcbCW2 qIOdkCqOdky+a7XwgTgDOXAIg/+zrq03/5Wy7LxH9fXcB7tMfkxyujJqFTQhtmD66TOI hBtpfKFu0jsrTb6eETBsiNBPTUO2Y4ioZZY53i5jMvy/HalQWM3yFuyTXFWQX9lckEo0 kwcJM6BmicpMhErQZwhT/2GHQZ9HFyKvuX67sxMmSjm83gNJrEjyNrWU6kyJHhst5xKz qm6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cJgwJOky; 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 e5-20020a17090ada0500b001bd14e01fcdsi3777890pjv.187.2022.04.06.01.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 01:50:34 -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=cJgwJOky; 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 06A752CDBCC; Wed, 6 Apr 2022 01:35:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352259AbiDEUfM (ORCPT + 99 others); Tue, 5 Apr 2022 16:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348240AbiDEJrR (ORCPT ); Tue, 5 Apr 2022 05:47:17 -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 2018AEACA2; Tue, 5 Apr 2022 02:33:32 -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 7FAFCB81C85; Tue, 5 Apr 2022 09:33:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2E08C385A2; Tue, 5 Apr 2022 09:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151210; bh=u1M5fWZoiYvm3eL5IGiUHURHVQOxWM5G0v5FSAtPShY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJgwJOkyRmZXyyEq1DB3PjbeiSpyq2Zjzfvr32dkzbeJmwRH35UK6Saj7lwp/2i2w LzvEE+dNgAvOq19BrIOebU7IFjKAcPpzGFSD9QndpH+efIsbteQhSLx68cjQCJhtm6 Y+HXL3wCvyXrb/quha6EtMpDAVo+Y9F9Q4F2Tc80= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.15 296/913] soc: qcom: rpmpd: Check for null return of devm_kcalloc Date: Tue, 5 Apr 2022 09:22:38 +0200 Message-Id: <20220405070348.729943511@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 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=no 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: Jiasheng Jiang [ Upstream commit 5a811126d38f9767a20cc271b34db7c8efc5a46c ] Because of the possible failure of the allocation, data->domains might be NULL pointer and will cause the dereference of the NULL pointer later. Therefore, it might be better to check it and directly return -ENOMEM without releasing data manually if fails, because the comment of the devm_kmalloc() says "Memory allocated with this function is automatically freed on driver detach.". Fixes: bbe3a66c3f5a ("soc: qcom: rpmpd: Add a Power domain driver to model corners") Signed-off-by: Jiasheng Jiang Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20211231094419.1941054-1-jiasheng@iscas.ac.cn Signed-off-by: Sasha Levin --- drivers/soc/qcom/rpmpd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index dbf494e92574..9f07274b0d28 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -546,6 +546,9 @@ static int rpmpd_probe(struct platform_device *pdev) data->domains = devm_kcalloc(&pdev->dev, num, sizeof(*data->domains), GFP_KERNEL); + if (!data->domains) + return -ENOMEM; + data->num_domains = num; for (i = 0; i < num; i++) { -- 2.34.1