soc: fsl: qbman: qman: avoid allocating from non existing gen_pool
authorAlexandre Belloni <[email protected]>
Thu, 23 Aug 2018 21:36:00 +0000 (23:36 +0200)
committerOlof Johansson <[email protected]>
Tue, 25 Sep 2018 20:57:25 +0000 (13:57 -0700)
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 <[email protected]>
Reviewed-by: Roy Pledge <[email protected]>
Signed-off-by: Li Yang <[email protected]>
(cherry picked from commit f72487a2788aa70c3aee1d0ebd5470de9bac953a)
Signed-off-by: Olof Johansson <[email protected]>
drivers/soc/fsl/qbman/qman.c

index ecb22749df0bfa4a4fc0596f8eb32a9b693c5004..8cc0151830433230e8f629c2660eec90871b7e8c 100644 (file)
@@ -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;