]> git.droids-corp.org - dpdk.git/commitdiff
app/testpmd: fix dereference before null check
authorSean Morrissey <sean.morrissey@intel.com>
Tue, 18 Jan 2022 10:53:09 +0000 (10:53 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 18 Jan 2022 13:02:48 +0000 (14:02 +0100)
Assign 'left' variable only after null check on 'size'
as function returns if 'size' is null.

Coverity issue: 374381
Fixes: 169a9fed1f4c ("app/testpmd: fix hex string parser support for flow API")
Cc: stable@dpdk.org
Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
app/test-pmd/cmdline_flow.c

index 5c2bba48ad2ab0b08675286c55d60cf32e6e1024..bbaf18d76eef2eabe145976947e5df7d2b985e7c 100644 (file)
@@ -7702,8 +7702,8 @@ error:
 static int
 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
 {
-       uint32_t left = *size;
        const uint8_t *head = dst;
+       uint32_t left;
 
        /* Check input parameters */
        if ((src == NULL) ||
@@ -7712,6 +7712,8 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
                (*size == 0))
                return -1;
 
+       left = *size;
+
        /* Convert chars to bytes */
        while (left) {
                char tmp[3], *end = tmp;