Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp721362pxb; Tue, 5 Apr 2022 20:17:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8lohnShA5JbZm5BuV9pv7iZGYkX1t2/JiSjDD3Ul9jU9NU7a+PFwOSB2JtFL3o0rqKLZ2 X-Received: by 2002:a17:902:e8cf:b0:156:36e0:6bcb with SMTP id v15-20020a170902e8cf00b0015636e06bcbmr6431703plg.105.1649215076554; Tue, 05 Apr 2022 20:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649215076; cv=none; d=google.com; s=arc-20160816; b=ATTbeQtfYCcV+tU2ey+lhdWTvTYLxMUXNSdo0K2YUhT0sZZXWQn91gsgWbLnXeIH5v Sm+wxDOse0kq+nVzHrreY36DmlyzFbWaukLnOzHlNc5g6E0DEypIsrjPwWs9z8fr70vi deajl33SV4yneuB1Lifn7GCRBlypjYDZ3vfegOR06i4M0P7eXE9uQb4hwTpi/RayNDNm xhV0jY8rqXj6X8Ly74i+yEPPt0PuotU8Gx8kBU3haaEssI3wlvrs6wZvZmD8sONS3u/a 9dY/r+loYLm/fEX8daSTiGSjeQiPA/uuOdXWy6gyq3BzncP7Dc0yTQrlu9D/nIyz1HGe n64A== 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=Es7YiGxN/uEGBpgg6J04z0vQBCOLA1vLAqXh9V9gx90=; b=PViUbJm+Vr+NBLp5am0W9s3quvhFgkj4VWanLm4Aaz5pqYpsq82clcU+rAvUTvnF4w /U7MKQahuyDy14If/4qwPocZ0TkUqsa+6GP9/O8VJgWnwAwtY6YtFUMNaMKDwL3UKYBc TpB11brcMPv7bBURd+Emrt905omsvZb789BUZAp7dJGJpfYjSQx4Nw/MsAA8uleLIAIv 9FFeqYRPA7SDSVP7yraAYO3zVs0Inr3bRzAR4n3tjrgAh2QUofHEyYMYbgmqmODRAxQg LZIH5oI2HDch7umqG25Z8ypTHebIcRysoC8wyx/EwFRZNXjytwxLg/pqvXrMHKa4fAWF nY/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LdpYGIl4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id 6-20020a631946000000b00398db2165basi12709953pgz.329.2022.04.05.20.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 20:17:56 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LdpYGIl4; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 4048F32E97F; Tue, 5 Apr 2022 19:54:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235441AbiDEIjx (ORCPT + 99 others); Tue, 5 Apr 2022 04:39:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234999AbiDEH7H (ORCPT ); Tue, 5 Apr 2022 03:59:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B9D655746; Tue, 5 Apr 2022 00:53:38 -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 dfw.source.kernel.org (Postfix) with ESMTPS id BBD9261781; Tue, 5 Apr 2022 07:53:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8A90C34113; Tue, 5 Apr 2022 07:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145217; bh=kpMFCZrNN6TOA8oXc55oqKYTMyz2RYpeQi/NLaMZq4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LdpYGIl4Q68xTOb2FjY7mjB/IrgoFUtDsWASysbmj5JSm8btyMH6iQmifoEjeHjFj WnNbaVMHv+xq8asJA99IeoiJn5pTn/1tN3x2idHyAj8XAKk64+2/UBjmRr3ifRIg+3 fp18SFfUHgIsAR8C93Bc20DMCjlzfbjuUbCMevuI= 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.17 0327/1126] soc: qcom: rpmpd: Check for null return of devm_kcalloc Date: Tue, 5 Apr 2022 09:17:54 +0200 Message-Id: <20220405070417.217444639@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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 0a8d8d24bfb7..624b5630feb8 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -610,6 +610,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