From patchwork Sun Oct 22 11:15:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alyssa Ross X-Patchwork-Id: 13431834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 70A1DC001DF for ; Sun, 22 Oct 2023 11:16:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zLnKn5Cq1JuH/Hm8QVIdRduKCu33CzQYKf8nEIAEM/U=; b=r7QJJwoDv/+cej erLorK1TE7XEaOYCIyDD243bJuamAgTWx602CxCfyV2EPVAc6qKE82a6u5fizd93i6Nbvqa0HDiYs V504u3liQbem8160EV0DaFS/a5N5fwzWgkTHWWp+W+PUtDyzhOh8k93+mDpgUyhaZrozw/216rnBt no5RrNe1ozYj2jynwGIeXTqVeIFyFup+ZlsdkqNVpC6YS32VbKpY/Z/+OYN53aAh8oVzEpA2EMgVJ tV7kwFl32+mx9pmmiiwIP6oOP5ZOEYBCGS5TguKmWfBiPAdTgFCVwakbN1RgtsK2M+QxIUuBbVKeu LerOmQuU9hLm1ziFUCxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1quWRL-005OZ5-3A; Sun, 22 Oct 2023 11:16:16 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1quWRI-005OY7-09 for linux-arm-kernel@lists.infradead.org; Sun, 22 Oct 2023 11:16:13 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 2DC955C034A; Sun, 22 Oct 2023 07:16:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 22 Oct 2023 07:16:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm2; t=1697973365; x=1698059765; bh=CWaua0x6Mk 9aPY5GqHx93n5yiwBj5JDvoi6q+zHqq34=; b=eExA4SgMkS98GusfiDlZCTMFGj Xqn1Til/upFxg0rTNtyZQjTF5XdiEd7oHKvO6Sv9240pfjIdu5XEQdalrkseMXQp Y5/vK+fKQ9+ZkvD7QvIL6rcJHokzf+gWSys/s3lg7X0XL7IiKdIZtK5nm9ZddWJm ib/y314ez3wqs4y5LtWszm2xwIII6E0UWmLRHtnyg4W+OpbtlmQ0DZv2Wuis4O92 81bptbuW2JIS0bAMgGetrL5syMbkpOSnaeD36LTciO5N19A+vgLSDnrYyO+hcUIT DZa1dU9cLODkcmJly6i7X3X0gdT7x3ppVc2IozMttXqq4ZsXx5mlNwm9ZuWw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1697973365; x=1698059765; bh=CWaua0x6Mk9aP Y5GqHx93n5yiwBj5JDvoi6q+zHqq34=; b=JpU5NuL75vEF+n0JSc2W5u09bMpXm fRSlUAigzJ5oevgSw/N3NN6XrHCDjsoy2G3kfBbqDkxEZbgkKq2TcWPWJvKJov55 KTjmdbb0+m+rIEqP+HBigKwvCoq26RMHI615BwLcFLcrE4jVqrwI2xyAoMLRLIJ9 mFNyRcUEvQkbJDeUXrNkwKiYJsHLBIpS4OKmq7SNwpdMRzduZ6tZhfvDaHnY8Bg9 nzYjQWFJVI2OStkXnHqjHe7lMqEHfa0RC9wNSlRq+CS5v6OoM+Gj6Kr8ZZHSpVNc llqLYo05yXvakEojOS/HnY67TSfdaORVCED2qZ0DReKFZ82YudW9Yk84w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrkeefgdefkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeetlhihshhsrgcu tfhoshhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpeehkefgtd evtedtkeduudeguefgudejheeugfelgeettdfhffduhfehudfhudeuhfenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehhihesrghlhihsshgrrd hish X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 22 Oct 2023 07:16:04 -0400 (EDT) Received: by mbp.qyliss.net (Postfix, from userid 1000) id 35CC61AB1; Sun, 22 Oct 2023 11:16:02 +0000 (UTC) From: Alyssa Ross To: Li Yang Cc: linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Claudiu Manoil , Roy Pledge , Scott Wood Subject: [PATCH] soc: fsl: qbman: fix null pointer dereference Date: Sun, 22 Oct 2023 11:15:37 +0000 Message-ID: <20231022111537.878237-1-hi@alyssa.is> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231022_041612_445106_FCFCC893 X-CRM114-Status: GOOD ( 10.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When called from bman_test_api(), bm_bpalloc may not have been initialized by fsl_bman_probe(), in which case gen_pool_alloc() would attempt to dereference a NULL pointer. Checking that bm_bpalloc is non-NULL allows boot to continue is this case. Fixes: 97e0d385b139 ("soc/bman: Add self-test for BMan driver") Signed-off-by: Alyssa Ross --- drivers/soc/fsl/qbman/bman.c | 3 +++ 1 file changed, 3 insertions(+) base-commit: 58720809f52779dc0f08e53e54b014209d13eebb diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c index 6cc1847e534a..713a0508678e 100644 --- a/drivers/soc/fsl/qbman/bman.c +++ b/drivers/soc/fsl/qbman/bman.c @@ -669,6 +669,9 @@ static int bm_alloc_bpid_range(u32 *result, u32 count) { unsigned long addr; + if (!bm_bpalloc) + return -ENXIO; + addr = gen_pool_alloc(bm_bpalloc, count); if (!addr) return -ENOMEM;