diff mbox series

[ovs-dev] ofp-port: Don't leak on error in ofputil_pull_ofp14_port_stats().

Message ID 20180914214329.8494-1-jpettit@ovn.org
State Accepted
Headers show
Series [ovs-dev] ofp-port: Don't leak on error in ofputil_pull_ofp14_port_stats(). | expand

Commit Message

Justin Pettit Sept. 14, 2018, 9:43 p.m. UTC
With this change, we can remove a case of free done in the error code
path.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
---
 lib/ofp-port.c  | 1 +
 lib/ofp-print.c | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

Comments

Yifeng Sun Sept. 14, 2018, 10:21 p.m. UTC | #1
Looks good, thanks for the fix.

Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>

On Fri, Sep 14, 2018 at 2:44 PM Justin Pettit <jpettit@ovn.org> wrote:

> With this change, we can remove a case of free done in the error code
> path.
>
> Signed-off-by: Justin Pettit <jpettit@ovn.org>
> ---
>  lib/ofp-port.c  | 1 +
>  lib/ofp-print.c | 1 -
>  2 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/ofp-port.c b/lib/ofp-port.c
> index ec70f46e96bb..3d1ada9ceb99 100644
> --- a/lib/ofp-port.c
> +++ b/lib/ofp-port.c
> @@ -1697,6 +1697,7 @@ ofputil_pull_ofp14_port_stats(struct
> ofputil_port_stats *ops,
>          }
>
>          if (error) {
> +            netdev_free_custom_stats_counters(&ops->custom_stats);
>              return error;
>          }
>      }
> diff --git a/lib/ofp-print.c b/lib/ofp-print.c
> index 37d7b8b98c55..e05a969a82b0 100644
> --- a/lib/ofp-print.c
> +++ b/lib/ofp-print.c
> @@ -558,7 +558,6 @@ ofp_print_ofpst_port_reply(struct ds *string, const
> struct ofp_header *oh,
>
>          retval = ofputil_decode_port_stats(&ps, &b);
>          if (retval) {
> -            netdev_free_custom_stats_counters(&ps.custom_stats);
>              return retval != EOF ? retval : 0;
>          }
>          ofputil_format_port_stats(string, &ps, port_map);
> --
> 2.17.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Justin Pettit Sept. 14, 2018, 11:46 p.m. UTC | #2
Thanks!  I pushed this to master and branch-2.10.

--Justin


> On Sep 14, 2018, at 3:21 PM, Yifeng Sun <pkusunyifeng@gmail.com> wrote:
> 
> Looks good, thanks for the fix.
> 
> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
> 
> On Fri, Sep 14, 2018 at 2:44 PM Justin Pettit <jpettit@ovn.org> wrote:
> With this change, we can remove a case of free done in the error code
> path.
> 
> Signed-off-by: Justin Pettit <jpettit@ovn.org>
> ---
>  lib/ofp-port.c  | 1 +
>  lib/ofp-print.c | 1 -
>  2 files changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/ofp-port.c b/lib/ofp-port.c
> index ec70f46e96bb..3d1ada9ceb99 100644
> --- a/lib/ofp-port.c
> +++ b/lib/ofp-port.c
> @@ -1697,6 +1697,7 @@ ofputil_pull_ofp14_port_stats(struct ofputil_port_stats *ops,
>          }
> 
>          if (error) {
> +            netdev_free_custom_stats_counters(&ops->custom_stats);
>              return error;
>          }
>      }
> diff --git a/lib/ofp-print.c b/lib/ofp-print.c
> index 37d7b8b98c55..e05a969a82b0 100644
> --- a/lib/ofp-print.c
> +++ b/lib/ofp-print.c
> @@ -558,7 +558,6 @@ ofp_print_ofpst_port_reply(struct ds *string, const struct ofp_header *oh,
> 
>          retval = ofputil_decode_port_stats(&ps, &b);
>          if (retval) {
> -            netdev_free_custom_stats_counters(&ps.custom_stats);
>              return retval != EOF ? retval : 0;
>          }
>          ofputil_format_port_stats(string, &ps, port_map);
> -- 
> 2.17.1
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox series

Patch

diff --git a/lib/ofp-port.c b/lib/ofp-port.c
index ec70f46e96bb..3d1ada9ceb99 100644
--- a/lib/ofp-port.c
+++ b/lib/ofp-port.c
@@ -1697,6 +1697,7 @@  ofputil_pull_ofp14_port_stats(struct ofputil_port_stats *ops,
         }
 
         if (error) {
+            netdev_free_custom_stats_counters(&ops->custom_stats);
             return error;
         }
     }
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 37d7b8b98c55..e05a969a82b0 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -558,7 +558,6 @@  ofp_print_ofpst_port_reply(struct ds *string, const struct ofp_header *oh,
 
         retval = ofputil_decode_port_stats(&ps, &b);
         if (retval) {
-            netdev_free_custom_stats_counters(&ps.custom_stats);
             return retval != EOF ? retval : 0;
         }
         ofputil_format_port_stats(string, &ps, port_map);