bond: fix for kvlist memory leak on rte_kvargs_process failure identified by klockwork scan
PATCH 1/1 bond: fix for kvlist memory leak on rte_kvargs_process failure identified by klockwork scan
Signed-off-by Declan Doherty <[email protected]>
--- lib/librte_pmd_bond/rte_eth_bond_pmd.c | 49 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-)
lib/librte_pmd_bond/rte_eth_bond_pmd.c +26 -23
@@ -1622,32 +1622,32 @@ bond_init(const char *name, const char *params)/* Parse link bonding mode */ if (rte_kvargs_count (kvlist,PMD_BOND_MODE_KVARG ) ==1 ) {if (rte_kvargs_process (kvlist,PMD_BOND_MODE_KVARG , - &bond_ethdev_parse_slave_mode_kvarg, &bonding_mode) !=0 ) { -RTE_LOG (ERR ,EAL ,"Invalid mode for bonded device %s\n" , name); -return -1 ; + &bond_ethdev_parse_slave_mode_kvarg, + &bonding_mode) !=0 ) { +RTE_LOG (ERR ,EAL ,"Invalid mode for bonded device %s\n" , + name); + goto parse_error; } }else { -RTE_LOG (ERR ,EAL , -"Mode must be specified only once for bonded device %s\n" , - name); -return -1 ; +RTE_LOG (ERR ,EAL ,"Mode must be specified only once for bonded " +"device %s\n" , name); + goto parse_error; }/* Parse socket id to create bonding device on */ arg_count =rte_kvargs_count (kvlist,PMD_BOND_SOCKET_ID_KVARG );if (arg_count ==1 ) {if (rte_kvargs_process (kvlist,PMD_BOND_SOCKET_ID_KVARG , - &bond_ethdev_parse_socket_id_kvarg, &socket_id) !=0 ) { -RTE_LOG (ERR ,EAL , -"Invalid socket Id specified for bonded device %s\n" , - name); -return -1 ; + &bond_ethdev_parse_socket_id_kvarg, &socket_id) + !=0 ) { +RTE_LOG (ERR ,EAL ,"Invalid socket Id specified for " +"bonded device %s\n" , name); + goto parse_error; } }else if (arg_count >1 ) { -RTE_LOG (ERR ,EAL , -"Socket Id can be specified only once for bonded device %s\n" , - name); -return -1 ; +RTE_LOG (ERR ,EAL ,"Socket Id can be specified only once for " +"bonded device %s\n" , name); + goto parse_error; }else { socket_id =rte_socket_id (); }
@@ -1655,18 +1655,21 @@ bond_init(const char *name, const char *params)/* Create link bonding eth device */ port_id =rte_eth_bond_create (name, bonding_mode, socket_id);if (port_id <0 ) { -RTE_LOG (ERR ,EAL , -"Failed to create socket %s in mode %u on socket %u.\n" , - name, bonding_mode, socket_id); -return -1 ; +RTE_LOG (ERR ,EAL ,"Failed to create socket %s in mode %u on " +"socket %u.\n" , name, bonding_mode, socket_id); + goto parse_error; } internals = rte_eth_devices[port_id].data->dev_private; internals->kvlist = kvlist; -RTE_LOG (INFO ,EAL , -"Create bonded device %s on port %d in mode %u on socket %u.\n" , - name, port_id, bonding_mode, socket_id); +RTE_LOG (INFO ,EAL ,"Create bonded device %s on port %d in mode %u on " +"socket %u.\n" , name, port_id, bonding_mode, socket_id);return 0 ; + +parse_error: +rte_kvargs_free (kvlist); + +return -1 ; }/* this part will resolve the slave portids after all the other pdev and vdev
Signature · 1 line
1.9.3
A message that is not in the archive (sent off-list or not yet received): 1423823246-32211-1-git-send-email-declan.doherty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Olivier MATZ
Acked-byHi,
Quoted 5 lines · Declan Doherty
Signed-off-by Declan Doherty <[email protected]>--- lib/librte_pmd_bond/rte_eth_bond_pmd.c | 49 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-)
Acked-by Olivier Matz <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Thomas Monjalon
AppliedQuoted 3 lines
Quoted 1 line
Signed-off-by Declan Doherty <[email protected]>Acked-by Olivier Matz <[email protected]>
Applied, thanks
De Lara Guarch, Pablo
Acked-byQuoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Declan Doherty
Sent: Friday, February 13, 2015 10:27 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH] bond: fix for kvlist memory leak onrte_kvargs_processfailure identified by klockwork scanSigned-off-by Declan Doherty <[email protected]>
Acked-by Pablo de Lara <[email protected]>