On 2015-02-26 07:42, Ouyang Changchun wrote: > Fix possible memory leak issue: free kvlist before return; > Fix possible resource lost issue: close qssockfd before return; > > Signed-off-by: Changchun Ouyang <changchun.ouyang at intel.com> > --- > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > index 80e9bdf..cf8f4fa 100644 > --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > @@ -694,6 +694,8 @@ error: > } > rte_free(*internals); > } > + if (qsockfd != -1) > + close(qsockfd); > return -1; > } > > @@ -822,16 +824,21 @@ rte_pmd_af_packet_devinit(const char *name, const char > *params) > > ret = rte_kvargs_process(kvlist, ETH_AF_PACKET_IFACE_ARG, > &open_packet_iface, &sockfd); > - if (ret < 0) > + if (ret < 0) { > + rte_kvargs_free(kvlist); > return -1; > + } > } > > ret = rte_eth_from_packet(name, &sockfd, numa_node, kvlist); > close(sockfd); /* no longer needed */ > > - if (ret < 0) > + if (ret < 0) { > + rte_kvargs_free(kvlist); > return -1; > + } > > + rte_kvargs_free(kvlist); > return 0; > } > >
This patch is correct but it would be good to rework it to have common error exit point like in rte_pmd_init_internals() function you changed. -- Pawel