[ovs-dev] flow: fix a possible memory leak in parse_ct_state

Message ID 1548654549-9016-1-git-send-email-lirongqing@baidu.com
State New
Headers show
Series
  • [ovs-dev] flow: fix a possible memory leak in parse_ct_state
Related show

Commit Message

Li RongQing Jan. 28, 2019, 5:49 a.m.
state_s should be freed always before exit parse_ct_state

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 lib/flow.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ilya Maximets Jan. 30, 2019, 2:10 p.m. | #1
On 28.01.2019 8:49, Li RongQing wrote:
> state_s should be freed always before exit parse_ct_state
> 

Fixes: b4293a336d8d ("conntrack: Move ct_state parsing to lib/flow.c")

> Signed-off-by: Li RongQing <lirongqing@baidu.com>

LGTM,
Acked-by: Ilya Maximets <i.maximets@samsung.com>

> ---
>  lib/flow.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/flow.c b/lib/flow.c
> index c6e47781b..479b7fe46 100644
> --- a/lib/flow.c
> +++ b/lib/flow.c
> @@ -1261,6 +1261,7 @@ parse_ct_state(const char *state_str, uint32_t default_state,
>          if (!bit) {
>              ds_put_format(ds, "%s: unknown connection tracking state flag",
>                            cs);
> +            free(state_s);
>              return false;
>          }
>          state |= bit;
>
Ben Pfaff Feb. 5, 2019, 12:18 a.m. | #2
On Wed, Jan 30, 2019 at 05:10:38PM +0300, Ilya Maximets wrote:
> On 28.01.2019 8:49, Li RongQing wrote:
> > state_s should be freed always before exit parse_ct_state
> > 
> 
> Fixes: b4293a336d8d ("conntrack: Move ct_state parsing to lib/flow.c")
> 
> > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> 
> LGTM,
> Acked-by: Ilya Maximets <i.maximets@samsung.com>

Thanks, applied to master, backported as far as branch-2.8.

Patch

diff --git a/lib/flow.c b/lib/flow.c
index c6e47781b..479b7fe46 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -1261,6 +1261,7 @@  parse_ct_state(const char *state_str, uint32_t default_state,
         if (!bit) {
             ds_put_format(ds, "%s: unknown connection tracking state flag",
                           cs);
+            free(state_s);
             return false;
         }
         state |= bit;