driver: net: fsl-mc: Check NULL before pointer dereference
authorPrabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Fri, 18 Mar 2016 10:46:03 +0000 (16:16 +0530)
committerYork Sun <york.sun@nxp.com>
Tue, 29 Mar 2016 15:46:01 +0000 (08:46 -0700)
NULL pointer should be checked before any dereference.  This patch
move memest after the NULL pointer check.

Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Reported-by: Jose Rivera <german.rivera@nxp.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: York Sun <york.sun@nxp.com>
drivers/net/fsl-mc/dpio/qbman_sys.h

index 235d641bd4c849b0b34ff6150c9872b940f76e7e..7a537fb82de1742cc9f9177197c53e5d0af7d773 100644 (file)
@@ -255,11 +255,11 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
        s->addr_cena = d->cena_bar;
        s->addr_cinh = d->cinh_bar;
        s->cena = (void *)valloc(CONFIG_SYS_PAGE_SIZE);
-       memset((void *)s->cena, 0x00, CONFIG_SYS_PAGE_SIZE);
        if (!s->cena) {
                printf("Could not allocate page for cena shadow\n");
                return -1;
        }
+       memset((void *)s->cena, 0x00, CONFIG_SYS_PAGE_SIZE);
 
 #ifdef QBMAN_CHECKING
        /* We should never be asked to initialise for a portal that isn't in