Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2455388imd; Fri, 2 Nov 2018 11:41:59 -0700 (PDT) X-Google-Smtp-Source: AJdET5cQKT0WSBQSxzwPyK6aeJj1UJ1Y58AU1exazn3UFy7dKUjJm2fz4loLeBuDUhEJfAH3/wKl X-Received: by 2002:a63:330e:: with SMTP id z14-v6mr11894004pgz.220.1541184119251; Fri, 02 Nov 2018 11:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184119; cv=none; d=google.com; s=arc-20160816; b=lijayu4MVu8tr5yjIfsI9zeNxPGKMc0CEglohAEyhgvnJNnZIIkUDzg61aW5uq0ZXi pFfESj7mzwN8DfBviTArrMXWQMt8DGy5hNgrZKmCZQakW+Toe8DNe5YFjflKy1/iwG6+ 8KFmPrCVNLjEuHviohQsaB0K+lxR/lXua4osnBfJxc1+r3uPKIa9fQ2xCOO2/D1qUurE dDM5Xuavnr3YaXJ87HIYjlZZ+bFPz7ki8CQuWandgK8ewR/ZD/ewY206yX7ibd7DQZfS i8CaU0vWKlbBwiGdDByGjEtlo1tC2gMZQHI7h24hT/4I1K7XQJiFb7Ekw+u5ChgnPHvm XWmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ngWu9OmOmIfn8SifDPeDDypn3zuTV5It0NQZmCJs6bA=; b=VjDd8/i6gKIJwDJK/ZpTUUP4aOYUjbhR7jGG0FyKLBfEUogqfQpzy639+Nv4MwHlD+ 55zQYUULMQeG5LhYtKEcT/IJVL87Tic6ICklqifdIPs9WJoRYM6XSa/tfQKK5Llz1GXv liLpAZX8AvO7+76WVsP8HvbPX1ryUZ8vQ3M/HQ3aWn/OkHSRZ7n67ibXBVGMIqUV0dCl wYdgN6Vl4zY6V2y/HR7Da2YBjJKpJ7smXgWvmChK/EOo41NQFBSHONkeWB0EFjnZ6LfT 3NWzWfz1ZC4Oto3HxujCcpru0nQFTEqJbqvMGEQ9NNNo6bYCkrW2ZQtlOMC7oSIjM1C4 QBoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OeJizFMP; 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 r24-v6si33707918pgv.380.2018.11.02.11.41.44; Fri, 02 Nov 2018 11:41:59 -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; dkim=pass header.i=@kernel.org header.s=default header.b=OeJizFMP; 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 S1729428AbeKCDsz (ORCPT + 99 others); Fri, 2 Nov 2018 23:48:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:43352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728578AbeKCDsy (ORCPT ); Fri, 2 Nov 2018 23:48:54 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 09C1D2082E; Fri, 2 Nov 2018 18:40:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184042; bh=F/9RQ7uxniS0vABGBN2ScMoqRnBFFFmh455iSD7Rbdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OeJizFMPqvBOgHW1swdZekYfzZC0F5Pa8O5egYTAywk1ZVsj/68gtNsKhdKo1yMtj c+wNBc3unP90hjlYQW9Ush9kB3ewn2yxZoIvjNjzMHJmQULlwtg9tbVlxcKExRVBf0 vtnTdcJSol8WPnhC1JRQoehN6PR0bQPBNYAkQvpM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Belloni , Roy Pledge , Li Yang , Olof Johansson , Sasha Levin Subject: [PATCH 4.18 021/150] soc: fsl: qbman: qman: avoid allocating from non existing gen_pool Date: Fri, 2 Nov 2018 19:33:03 +0100 Message-Id: <20181102182904.502472305@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 64e9e22e68512da8df3c9a7430f07621e48db3c2 ] 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 Signed-off-by: Li Yang (cherry picked from commit f72487a2788aa70c3aee1d0ebd5470de9bac953a) Signed-off-by: Olof Johansson Signed-off-by: Sasha Levin --- 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.17.1