From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.bootlin.com (mail.bootlin.com [62.4.15.54]) by lists.ozlabs.org (Postfix) with ESMTP id 41xHlz02P8zDqBy for ; Fri, 24 Aug 2018 07:36:10 +1000 (AEST) From: Alexandre Belloni To: Li Yang Cc: Roy Pledge , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandre Belloni 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> In-Reply-To: <20180823213600.23426-1-alexandre.belloni@bootlin.com> References: <20180823213600.23426-1-alexandre.belloni@bootlin.com> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 --- 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; -- 2.18.0