Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2193838iof; Tue, 7 Jun 2022 22:48:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH4S12Jnkb4p4x8yRAT5ngYej0+UbiECs1zRUtcPVmyyIIdXgW7mlVxfb8chqSxZEhtpUD X-Received: by 2002:a17:902:f708:b0:153:839f:bf2c with SMTP id h8-20020a170902f70800b00153839fbf2cmr32760888plo.113.1654667282810; Tue, 07 Jun 2022 22:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667282; cv=none; d=google.com; s=arc-20160816; b=Q1tXMH3l/20ifUaLkCdG0T5Nhlx2a/ObOPgmLgBF/HYO5nMjoVMTf73zzuNTTyFZZw 0GTEmbB+IaH8qvbXAryq7greCcE+NpaLXPHm0L6DK6C0/AFalV3yCuiSpz1Bm2HrSJqm p+THlxgs8CQKOKeprPD6+eXt08iXpeS99eWtBrwK4aTQANmjddhmBnUtrjaHvEKKmTWa aBb8Th7Y61YOQ0sLVIqkqYr4ytQhSGT9Vn67fr0F3I6oS0KtzPVvf5P5Fav01NiNqyfP n7WPNiAk+bwMTcGwBM+g/O+1Z2M0YZaHYDMXQdy7rrNb9+OhZouGOxJpffQ2/JWv8oLf b5og== 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=9p7+RkMt+h5QonuER+sJXP+ih3Ygw82cibY2v1UyAS4=; b=wmqZWdsc2R/hPHdT80uib/UEC/lgSyuwPUdmXinrBCkjmyKdHF6FGjXs0jxry0uR0+ vkJRziUGXJ70WiPkE25pdVRvp74YeHT8z0h54BHNJWUc0pRKqRTI1q6wtqvWS0JSsomX /oAooWNZy66C2gjd101MCORIQ6RIZz97bRhRkVaVczM7wpu+7661AchzsWjaVMjFr7hD ckbx5uSJXwjyZf/DtiBUFNgPVIGFlCbL1xLaEKCfTwMhWVh1TFlT9qS8qBTODPLEOKQK geOk9co9jak7BlhxPalRhES9MeWBtwI1twWhJBnRgpCMuGDDervbYmQCxNIH7PhmJJZy RQ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WhCIjNBa; 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 bj9-20020a17090b088900b001d29340d056si15080328pjb.44.2022.06.07.22.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:48:02 -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=WhCIjNBa; 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 A473A415238; Tue, 7 Jun 2022 22:14:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391127AbiFHAhE (ORCPT + 99 others); Tue, 7 Jun 2022 20:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382748AbiFGWDw (ORCPT ); Tue, 7 Jun 2022 18:03:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A403194BFF; Tue, 7 Jun 2022 12:14:54 -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 E5C48B8233E; Tue, 7 Jun 2022 19:14:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38591C385A2; Tue, 7 Jun 2022 19:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629288; bh=Fj/fW43wd9kwqA+LnYirM/9rZBHeydYkYqpZlhxcRNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WhCIjNBa8qbpj28XMx2qV3PWXU292f1W9v31ysbyKUgBCdUbDLfsHnOErrwSaQokN HtaOwUwWW1IKJyj9u+2z8VDjO1Lbz9RdBUc3BgDbfEWssMSH5LRMF8oib9Fx4HYvtC nPCSRdXA8bWh3HDUqcmyCWfzvHjk+cfqfYgecUOg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, QintaoShen , Florian Fainelli , Sasha Levin Subject: [PATCH 5.18 586/879] soc: bcm: Check for NULL return of devm_kzalloc() Date: Tue, 7 Jun 2022 19:01:44 +0200 Message-Id: <20220607165019.862167410@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 b4bd2aafacce48db26b0a213d849818d940556dd ] As the potential failure of allocation, devm_kzalloc() may return NULL. Then the 'pd->pmb' and the follow lines of code may bring null pointer dereference. Therefore, it is better to check the return value of devm_kzalloc() to avoid this confusion. Fixes: 8bcac4011ebe ("soc: bcm: add PM driver for Broadcom's PMB") Signed-off-by: QintaoShen Signed-off-by: Florian Fainelli Signed-off-by: Sasha Levin --- drivers/soc/bcm/bcm63xx/bcm-pmb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soc/bcm/bcm63xx/bcm-pmb.c b/drivers/soc/bcm/bcm63xx/bcm-pmb.c index 7bbe46ea5f94..9407cac47fdb 100644 --- a/drivers/soc/bcm/bcm63xx/bcm-pmb.c +++ b/drivers/soc/bcm/bcm63xx/bcm-pmb.c @@ -312,6 +312,9 @@ static int bcm_pmb_probe(struct platform_device *pdev) for (e = table; e->name; e++) { struct bcm_pmb_pm_domain *pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); + if (!pd) + return -ENOMEM; + pd->pmb = pmb; pd->data = e; pd->genpd.name = e->name; -- 2.35.1