diff options
author | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2018-08-23 23:36:00 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-11-04 14:52:38 +0100 |
commit | 795b13034224f1b82fc22d749f9226a8c97977d4 (patch) | |
tree | b2ffd67c522f89d8e5054aec1ca602f4488f6e39 | |
parent | d9e742766c763db1e8ead9a9fbd7640232735ede (diff) | |
download | linux-stable-795b13034224f1b82fc22d749f9226a8c97977d4.tar.gz linux-stable-795b13034224f1b82fc22d749f9226a8c97977d4.tar.bz2 linux-stable-795b13034224f1b82fc22d749f9226a8c97977d4.zip |
soc: fsl: qbman: qman: avoid allocating from non existing gen_pool
[ 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 <alexandre.belloni@bootlin.com>
Reviewed-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
(cherry picked from commit f72487a2788aa70c3aee1d0ebd5470de9bac953a)
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/soc/fsl/qbman/qman.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c index 0c6065dba48a..4f27e95efcdd 100644 --- a/drivers/soc/fsl/qbman/qman.c +++ b/drivers/soc/fsl/qbman/qman.c @@ -2699,6 +2699,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; |