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: 156530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp709004vqx; Sun, 22 Oct 2023 04:16:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHN3hbzvlUYRr/1matECqHDrWhUxLf+IfWTcKYKN3OTFtko3jtf/fqFmkRLWyjiaBxwGZSB X-Received: by 2002:a05:6808:1151:b0:3ae:156f:d319 with SMTP id u17-20020a056808115100b003ae156fd319mr7949281oiu.45.1697973409424; Sun, 22 Oct 2023 04:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697973409; cv=none; d=google.com; s=arc-20160816; b=Vdfgqp7bZW1OgtMA50C96IZ1wX+JCWr3DEiIMc4eXiitk8HK9ZnTBZS9en/GpJr/4Z JhwL7Bzkbs3qZ7MNEXAXFFJKXHkEKCgVGdGAmXLtF85wtY09C84idEby3Pp0j8qmDFIT UO87O4RyXTOGqNHVaXF2X/bS7o/ft1hzEMAl9H48bYLwrnTywC+iMCYtKuSqzdfIe6gR /HLxw/DpOduKU16EQWKx/uh6WA/5qizbwOM262i4xOVeg+wA6VGwtwttqMsiuPWo5HtC 3EaGO9EJWMIsy0XhUAySLf8fVrrhfzrhLUVHv4qnFSdJIO2RGfUh9xx+u5dJQPMN4ATA yicg== 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 :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=CWaua0x6Mk9aPY5GqHx93n5yiwBj5JDvoi6q+zHqq34=; fh=jICbG6uVPKocyk5xmo2wIH01UnpgtIvjxrtxEOOydnc=; b=h7UShLn23XwvS2vaRcsI39W1Ng2J4Qy9xqyMekTKi53pIeZWKYV1C0olxtHHglJ7dJ 6um+eZkZkRhLXSXnp4UjLMbZrO8nNlrkU6YIeixm3iABwz1vFn+pva7CFYZum4obNfs3 sA6JL37RjyFOJoMUojBnX5nhO+i4R7FNVP+ec1C5jnzWqz8wRKVenNDeyZmq6+V5tWD5 QrZ30CaWzkF8B4NyWDae3wUVu/FIByTdx8EZqtIW/ZXUHKbRtTH/KoicOXQUn7sg+vNh a0sXte4hcu5yVAr1BBAyrtlPJp3hD5KXoq2JiYjET8umqgQvJg4JoINKf5zS8Zk2jM36 fq0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alyssa.is header.s=fm2 header.b=eExA4SgM; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=JpU5NuL7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id f21-20020a63f115000000b005b8549f737dsi4792539pgi.708.2023.10.22.04.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 04:16:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@alyssa.is header.s=fm2 header.b=eExA4SgM; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=JpU5NuL7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C238780747A9; Sun, 22 Oct 2023 04:16:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231552AbjJVLQK (ORCPT + 25 others); Sun, 22 Oct 2023 07:16:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231537AbjJVLQI (ORCPT ); Sun, 22 Oct 2023 07:16:08 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75D5EB for ; Sun, 22 Oct 2023 04:16:05 -0700 (PDT) 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-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 22 Oct 2023 04:16:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780454165730091880 X-GMAIL-MSGID: 1780454165730091880 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;