From patchwork Thu Aug 23 21:36:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 10574591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A37C61579 for ; Thu, 23 Aug 2018 21:36:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96A842C63C for ; Thu, 23 Aug 2018 21:36:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B0892C7F2; Thu, 23 Aug 2018 21:36:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 246462C63C for ; Thu, 23 Aug 2018 21:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0y9R908jM8IqcdeLQpxiFJ0lCDw0UTSdxAgRpX4RK50=; b=KfrKWOqIdm5hn244gqz+2zgVrf 4PVkIe7dr8wlGlHoVme6RAB4RtuQbpLEz9nIO6t9YZDDAQtQqI9Uq1WyVaKJqasMHLXlya7+6fOmC sFk+fMIy/dLFWZBhasfla5IITcICifz2yLLLVB2aRPv4jruxSAbzL9w1A2GBwBOllpxRsfMeKkbX9 Vdb3d2R3CEY3SHBr7P0Deb+4stPL45vBaNdplLTzQoNLUDzc0DcKIkfB4nTgTclRoyj/6PdE/NJPN n6nuv3XzIz8Q8xuX6AI9mPm4tDbQFKXNwI0wYIMktRwxTAA2TtH0t8wYQGWHudRrwVBsN/YIw39Ix rL+DEpyg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsxHI-00018t-NY; Thu, 23 Aug 2018 21:36:28 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsxH9-0000zR-Ay for linux-arm-kernel@lists.infradead.org; Thu, 23 Aug 2018 21:36:20 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 9B267207B3; Thu, 23 Aug 2018 23:36:07 +0200 (CEST) Received: from localhost (unknown [88.191.26.124]) by mail.bootlin.com (Postfix) with ESMTPSA id 77BE6204AE; Thu, 23 Aug 2018 23:36:07 +0200 (CEST) From: Alexandre Belloni To: Li Yang Subject: [PATCH 2/2] soc: fsl: qbman: qman: avoid allocating from non existing gen_pool Date: Thu, 23 Aug 2018 23:36:00 +0200 Message-Id: <20180823213600.23426-2-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823213600.23426-1-alexandre.belloni@bootlin.com> References: <20180823213600.23426-1-alexandre.belloni@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180823_143619_514717_A27412B8 X-CRM114-Status: UNSURE ( 9.34 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Roy Pledge , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the qman driver didn't probe, calling qman_alloc_fqid_range, qman_alloc_pool_range or qman_alloc_cgrid_range (as done in dpaa_eth) will pass a NULL pointer to gen_pool_alloc, leading to a NULL pointer dereference. Signed-off-by: Alexandre Belloni Reviewed-by: Roy Pledge --- drivers/soc/fsl/qbman/qman.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c index ecb22749df0b..8cc015183043 100644 --- a/drivers/soc/fsl/qbman/qman.c +++ b/drivers/soc/fsl/qbman/qman.c @@ -2729,6 +2729,9 @@ static int qman_alloc_range(struct gen_pool *p, u32 *result, u32 cnt) { unsigned long addr; + if (!p) + return -ENODEV; + addr = gen_pool_alloc(p, cnt); if (!addr) return -ENOMEM;