null: fix dereference before null check
authorTetsuya Mukawa <mukawa@igel.co.jp>
Mon, 16 Mar 2015 03:43:21 +0000 (12:43 +0900)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 17 Mar 2015 22:01:31 +0000 (23:01 +0100)
This patch fixes potential null pointer access of eth_null_copy_tx().

Reported-by: John Mcnamara <john.mcnamara@intel.com>
Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
lib/librte_pmd_null/rte_eth_null.c

index 8fe1a2d..0e18502 100644 (file)
@@ -160,11 +160,12 @@ eth_null_copy_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
        int i;
        struct null_queue *h = q;
-       unsigned packet_size = h->internals->packet_size;
+       unsigned packet_size;
 
        if ((q == NULL) || (bufs == NULL))
                return 0;
 
+       packet_size = h->internals->packet_size;
        for (i = 0; i < nb_bufs; i++) {
                rte_memcpy(h->dummy_packet, rte_pktmbuf_mtod(bufs[i], void *),
                                        packet_size);