Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2119112imm; Thu, 23 Aug 2018 14:37:32 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzfsHwAkey8udWZkfV/54SOZPio5Z43XB8IjSVohbbWcF4XBhr17aIdcbHOQX8rEVGxI2Ch X-Received: by 2002:a63:1c47:: with SMTP id c7-v6mr18992206pgm.38.1535060252904; Thu, 23 Aug 2018 14:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535060252; cv=none; d=google.com; s=arc-20160816; b=1Cfhu3Tj5g49QC6WXHD0ovuegbzr8GoBz0bSyCVDIn9JDktByqhmDPIOhLuhLCqEMB 0ovace33fEs4OS3V8TUT0iQA6rqGosKzXHk4GDM1l1j3pRg2R+75lLpD6lpNU9lk2/rN /gSedsop5keKeaBVXphC6ZoizIS3lCEZ3PnDKvV+U8yB9roPDymOiaEOImamK4UmF8E6 b5p58GNBPl37vmhbIBStaiBmdjgEsuUovDSQTQnVA5MOTWZwvDnpYCTZ1nMjwAivBtVR sSv6Muk4xgxfH1GXxU1Y8oMvfe+MbdZdmsUp0xRr25B702At9XZsjhJx/yKd4VScbOqs ndnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=wBgwHNzuxUlP4JF/f62IoxZ3T3Kk9sZ3bqM9CwHUZH0=; b=oUZiK+jXiCjzXBScyf6uq9ugJmXBUJC8Ql8ffNmT5M1AZWF8RUL9J0Rxolj8OU6xLQ +uIuEubWmPv54VhJZFGmefnugUw9n5pb2qlZ8ILbWarWdUbCgJaL5CsvdlHceIMExWK6 CdbjVG0tuofZKC6Chp1VXsMRFNCmcJbnw3eq5zVvODo7LNUImFCUFMpDdB/q402YC965 TapMc/0dlAsr50IuWts1/xqmYthk2eg/DoBLuJyTUANu5OKX9qIIfn2CiFFEVS2SR2ws xWsgCZ4Hd89uISLyzCv4OWHHXuGKMlNfMyOYapKE6skyi3Bp+LhJNU8fHEkdleHIbeJG oWag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e34-v6si5464412plb.2.2018.08.23.14.37.17; Thu, 23 Aug 2018 14:37:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728239AbeHXBHr (ORCPT + 99 others); Thu, 23 Aug 2018 21:07:47 -0400 Received: from mail.bootlin.com ([62.4.15.54]:50817 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728108AbeHXBHp (ORCPT ); Thu, 23 Aug 2018 21:07:45 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 9B267207B3; Thu, 23 Aug 2018 23:36:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 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 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> 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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