soc: fsl: dpio: fix dereference of pointer p before null check
authorColin Ian King <colin.king@canonical.com>
Fri, 21 Feb 2020 23:11:43 +0000 (23:11 +0000)
committerLi Yang <leoyang.li@nxp.com>
Fri, 21 Feb 2020 23:17:42 +0000 (17:17 -0600)
Pointer p is currently being dereferenced before it is null
checked on a memory allocation failure check. Fix this by
checking if p is null before dereferencing it.

Addresses-Coverity: ("Dereference before null check")
Fixes: 3b2abda7d28c ("soc: fsl: dpio: Replace QMAN array mode with ring mode enqueue")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
drivers/soc/fsl/dpio/qbman-portal.c

index 740ee0d..d1f49ca 100644 (file)
@@ -249,10 +249,11 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
        u32 mask_size;
        u32 eqcr_pi;
 
-       spin_lock_init(&p->access_spinlock);
-
        if (!p)
                return NULL;
+
+       spin_lock_init(&p->access_spinlock);
+
        p->desc = d;
        p->mc.valid_bit = QB_VALID_BIT;
        p->sdq = 0;