* [PATCH] af_packet: fix possible memory leak @ 2014-12-19 15:01 Daniel Mrzyglod [not found] ` <1419001296-8300-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Daniel Mrzyglod @ 2014-12-19 15:01 UTC (permalink / raw) To: dev-VfR2kkLFssw In rte_pmd_init_internals, we are mapping memory but not released if error occure it could produce memoryleak. Add unmmap function to release memory. Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> --- lib/librte_pmd_af_packet/rte_eth_af_packet.c | 7 +++++++ 1 file changed, 7 insertions(+) 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 236749b..93e6b6b 100644 --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c @@ -481,6 +481,11 @@ rte_pmd_init_internals(const char *name, if (*internals == NULL) goto error; + for (q = 0; q < nb_queues; q++) { + (*internals)->rx_queue[q].map = MAP_FAILED; + (*internals)->tx_queue[q].map = MAP_FAILED; + } + req = &((*internals)->req); req->tp_block_size = blocksize; @@ -682,6 +687,8 @@ error: rte_free(pci_dev); if (*internals) { for (q = 0; q < nb_queues; q++) { + munmap((*internals)->rx_queue[q].map, + 2 * req->tp_block_size * req->tp_block_nr); if ((*internals)->rx_queue[q].rd) rte_free((*internals)->rx_queue[q].rd); if ((*internals)->tx_queue[q].rd) -- 2.1.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <1419001296-8300-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] af_packet: fix possible memory leak [not found] ` <1419001296-8300-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> @ 2014-12-19 15:47 ` Jastrzebski, MichalX K 2014-12-19 19:35 ` John W. Linville 1 sibling, 0 replies; 4+ messages in thread From: Jastrzebski, MichalX K @ 2014-12-19 15:47 UTC (permalink / raw) To: Mrzyglod, DanielX T, dev-VfR2kkLFssw@public.gmane.org > -----Original Message----- > From: dev [mailto:dev-bounces-VfR2kkLFssw@public.gmane.org] On Behalf Of Daniel Mrzyglod > Sent: Friday, December 19, 2014 4:02 PM > To: dev-VfR2kkLFssw@public.gmane.org > Subject: [dpdk-dev] [PATCH] af_packet: fix possible memory leak > > In rte_pmd_init_internals, we are mapping memory but not released > if error occure it could produce memoryleak. > Add unmmap function to release memory. > > Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > --- > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > 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 236749b..93e6b6b 100644 > --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > @@ -481,6 +481,11 @@ rte_pmd_init_internals(const char *name, > if (*internals == NULL) > goto error; > > + for (q = 0; q < nb_queues; q++) { > + (*internals)->rx_queue[q].map = MAP_FAILED; > + (*internals)->tx_queue[q].map = MAP_FAILED; > + } > + > req = &((*internals)->req); > > req->tp_block_size = blocksize; > @@ -682,6 +687,8 @@ error: > rte_free(pci_dev); > if (*internals) { > for (q = 0; q < nb_queues; q++) { > + munmap((*internals)->rx_queue[q].map, > + 2 * req- > >tp_block_size * req->tp_block_nr); > if ((*internals)->rx_queue[q].rd) > rte_free((*internals)->rx_queue[q].rd); > if ((*internals)->tx_queue[q].rd) > -- > 2.1.0 Acked-by: Michal Jastrzebski <michalx.k.jastrzebski-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] af_packet: fix possible memory leak [not found] ` <1419001296-8300-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 2014-12-19 15:47 ` Jastrzebski, MichalX K @ 2014-12-19 19:35 ` John W. Linville [not found] ` <20141219193539.GA32707-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> 1 sibling, 1 reply; 4+ messages in thread From: John W. Linville @ 2014-12-19 19:35 UTC (permalink / raw) To: Daniel Mrzyglod; +Cc: dev-VfR2kkLFssw On Fri, Dec 19, 2014 at 04:01:36PM +0100, Daniel Mrzyglod wrote: > In rte_pmd_init_internals, we are mapping memory but not released > if error occure it could produce memoryleak. > Add unmmap function to release memory. > > Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > --- > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 7 +++++++ > 1 file changed, 7 insertions(+) Acked-by: John W. Linville <linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> -- John W. Linville Someday the world will need a hero, and you linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org might be all we have. Be ready. ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20141219193539.GA32707-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>]
* Re: [PATCH] af_packet: fix possible memory leak [not found] ` <20141219193539.GA32707-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> @ 2014-12-19 22:34 ` Thomas Monjalon 0 siblings, 0 replies; 4+ messages in thread From: Thomas Monjalon @ 2014-12-19 22:34 UTC (permalink / raw) To: Daniel Mrzyglod; +Cc: dev-VfR2kkLFssw > > In rte_pmd_init_internals, we are mapping memory but not released > > if error occure it could produce memoryleak. > > Add unmmap function to release memory. > > > > Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > > Acked-by: John W. Linville <linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> Applied Thanks -- Thomas ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-19 22:34 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-12-19 15:01 [PATCH] af_packet: fix possible memory leak Daniel Mrzyglod [not found] ` <1419001296-8300-1-git-send-email-danielx.t.mrzyglod-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 2014-12-19 15:47 ` Jastrzebski, MichalX K 2014-12-19 19:35 ` John W. Linville [not found] ` <20141219193539.GA32707-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> 2014-12-19 22:34 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).