[dpdk-dev] examples/bond: add mbuf alloc check

Message ID 1516639016-28269-1-git-send-email-radu.nicolau@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Radu Nicolau Jan. 22, 2018, 4:36 p.m. UTC
  Fixes Coverity issue 257008

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 examples/bond/main.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

John McNamara Jan. 23, 2018, 5:42 p.m. UTC | #1
> -----Original Message-----
> From: Nicolau, Radu
> Sent: Monday, January 22, 2018 4:37 PM
> To: dev@dpdk.org
> Cc: Kovacevic, Marko <marko.kovacevic@intel.com>; Mcnamara, John
> <john.mcnamara@intel.com>; Doherty, Declan <declan.doherty@intel.com>;
> Nicolau, Radu <radu.nicolau@intel.com>
> Subject: [PATCH] examples/bond: add mbuf alloc check
> 
> Fixes Coverity issue 257008
> 

Hi Radu,

You should also include the fixes line in the commit message and CC stable@dpdk.org as well:

    Fixes: cc7e8ae84faa ("examples/bond: add example application for link bonding mode 6")
    Coverity issue: 257008
    Cc: stable@dpdk.org

John
  

Patch

diff --git a/examples/bond/main.c b/examples/bond/main.c
index 01e5eda..6c8a44a 100644
--- a/examples/bond/main.c
+++ b/examples/bond/main.c
@@ -441,6 +441,11 @@  static void cmd_obj_send_parsed(void *parsed_result,
 				(BOND_IP_3 << 16) | (BOND_IP_4 << 24);
 
 	created_pkt = rte_pktmbuf_alloc(mbuf_pool);
+	if (created_pkt == NULL) {
+		cmdline_printf(cl, "Failed to allocate mbuf\n");
+		return;
+	}
+
 	pkt_size = sizeof(struct ether_hdr) + sizeof(struct arp_hdr);
 	created_pkt->data_len = pkt_size;
 	created_pkt->pkt_len = pkt_size;