[2/2] sched: fix possible mem leak on initialize

Message ID 1543413355-2874-2-git-send-email-xiangxia.m.yue@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Cristian Dumitrescu
Headers
Series [1/2] sched: refine get base helper function |

Checks

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

Commit Message

Tonghao Zhang Nov. 28, 2018, 1:55 p.m. UTC
  In some case, we may create sched port dynamically,
if err when creating so memory will leak.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 lib/librte_sched/rte_sched.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Tonghao Zhang Dec. 11, 2018, 2:54 a.m. UTC | #1
ping
On Wed, Nov 28, 2018 at 9:56 PM Tonghao Zhang <xiangxia.m.yue@gmail.com> wrote:
>
> In some case, we may create sched port dynamically,
> if err when creating so memory will leak.
>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
>  lib/librte_sched/rte_sched.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
> index 17de6e6..a3adcca 100644
> --- a/lib/librte_sched/rte_sched.c
> +++ b/lib/librte_sched/rte_sched.c
> @@ -724,6 +724,7 @@ struct rte_sched_port *
>                                     bmp_mem_size);
>         if (port->bmp == NULL) {
>                 RTE_LOG(ERR, SCHED, "Bitmap init error\n");
> +               rte_free(port);
>                 return NULL;
>         }
>
> --
> 1.8.3.1
>
  
Cristian Dumitrescu Dec. 20, 2018, 7:09 p.m. UTC | #2
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tonghao Zhang
> Sent: Tuesday, December 11, 2018 2:54 AM
> To: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 2/2] sched: fix possible mem leak on initialize
> 
> ping
> On Wed, Nov 28, 2018 at 9:56 PM Tonghao Zhang
> <xiangxia.m.yue@gmail.com> wrote:
> >
> > In some case, we may create sched port dynamically,
> > if err when creating so memory will leak.
> >
> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > ---
> >  lib/librte_sched/rte_sched.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
> > index 17de6e6..a3adcca 100644
> > --- a/lib/librte_sched/rte_sched.c
> > +++ b/lib/librte_sched/rte_sched.c
> > @@ -724,6 +724,7 @@ struct rte_sched_port *
> >                                     bmp_mem_size);
> >         if (port->bmp == NULL) {
> >                 RTE_LOG(ERR, SCHED, "Bitmap init error\n");
> > +               rte_free(port);
> >                 return NULL;
> >         }
> >
> > --
> > 1.8.3.1
> >

Also fixed another identical issue in the same function.

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied to next-qos tree, thanks!
  

Patch

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index 17de6e6..a3adcca 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -724,6 +724,7 @@  struct rte_sched_port *
 				    bmp_mem_size);
 	if (port->bmp == NULL) {
 		RTE_LOG(ERR, SCHED, "Bitmap init error\n");
+		rte_free(port);
 		return NULL;
 	}