From 8d59064fb3c323f3fcc6441fc262d04611b794a0 Mon Sep 17 00:00:00 2001 From: Tetsuya Mukawa Date: Mon, 16 Mar 2015 12:43:21 +0900 Subject: [PATCH] null: fix dereference before null check This patch fixes potential null pointer access of eth_null_copy_tx(). Reported-by: John Mcnamara Signed-off-by: Tetsuya Mukawa --- lib/librte_pmd_null/rte_eth_null.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_pmd_null/rte_eth_null.c b/lib/librte_pmd_null/rte_eth_null.c index 8fe1a2d554..0e18502704 100644 --- a/lib/librte_pmd_null/rte_eth_null.c +++ b/lib/librte_pmd_null/rte_eth_null.c @@ -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); -- 2.20.1