test/crypto: fix mbuf reset after null check
authorThierry Herbelot <thierry.herbelot@6wind.com>
Mon, 24 May 2021 09:01:13 +0000 (11:01 +0200)
committerAkhil Goyal <gakhil@marvell.com>
Wed, 7 Jul 2021 19:28:39 +0000 (21:28 +0200)
Use m only after it was checked not to be NULL.

Fixes: 202d375c60bc1 ("app/test: add cryptodev unit and performance tests")
Cc: stable@dpdk.org
Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
app/test/test_cryptodev.c

index ead8c6e..dd1669e 100644 (file)
@@ -135,10 +135,11 @@ setup_test_string(struct rte_mempool *mpool,
        struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
        size_t t_len = len - (blocksize ? (len % blocksize) : 0);
 
-       memset(m->buf_addr, 0, m->buf_len);
        if (m) {
-               char *dst = rte_pktmbuf_append(m, t_len);
+               char *dst;
 
+               memset(m->buf_addr, 0, m->buf_len);
+               dst = rte_pktmbuf_append(m, t_len);
                if (!dst) {
                        rte_pktmbuf_free(m);
                        return NULL;