diff mbox series

[ovs-dev,2/2] Datapath: Fix ovs_vport_init unreachable code and goto labels

Message ID 20180709130945.3840-1-aserdean@ovn.org
State Changes Requested
Headers show
Series [ovs-dev,1/2] Datapath: Cleanup compat ip6_tunnel.c | expand

Commit Message

Alin-Gabriel Serdean July 9, 2018, 1:09 p.m. UTC
The line "ovs_stt_cleanup_module();" was unreachable. Looking
at the rest of the goto labels they also seem wrong, so fix them also.

Found using static analysis tools.

Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
---
 datapath/vport.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Comments

Yifeng Sun July 9, 2018, 6:04 p.m. UTC | #1
I think the correct fix may be as follows, do you mind rechecking it?
Thanks.

diff --git a/datapath/vport.c b/datapath/vport.c
index 02f6b56d3243..fcf0fea0a245 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -93,7 +93,6 @@ int ovs_vport_init(void)
                goto err_stt;

        return 0;
-       ovs_stt_cleanup_module();
 err_stt:
        vxlan_cleanup_module();
 err_vxlan:

On Mon, Jul 9, 2018 at 6:09 AM, Alin Gabriel Serdean <aserdean@ovn.org>
wrote:

> The line "ovs_stt_cleanup_module();" was unreachable. Looking
> at the rest of the goto labels they also seem wrong, so fix them also.
>
> Found using static analysis tools.
>
> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
> ---
>  datapath/vport.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/datapath/vport.c b/datapath/vport.c
> index 02f6b56d3..5f11dd6ad 100644
> --- a/datapath/vport.c
> +++ b/datapath/vport.c
> @@ -93,22 +93,23 @@ int ovs_vport_init(void)
>                 goto err_stt;
>
>         return 0;
> -       ovs_stt_cleanup_module();
> +
>  err_stt:
> -       vxlan_cleanup_module();
> +       ovs_stt_cleanup_module();
>  err_vxlan:
> -       geneve_cleanup_module();
> +       vxlan_cleanup_module();
>  err_geneve:
> -       ip6_tunnel_cleanup();
> +       geneve_cleanup_module();
>  err_ip6_tunnel:
> -       ip6gre_fini();
> +       ip6_tunnel_cleanup();
>  err_ip6gre:
> -       ipgre_fini();
> +       ip6gre_fini();
>  err_ipgre:
> -       gre_exit();
> +       ipgre_fini();
>  err_gre:
> -       lisp_cleanup_module();
> +       gre_exit();
>  err_lisp:
> +       lisp_cleanup_module();
>         kfree(dev_table);
>         return err;
>  }
> --
> 2.16.1.windows.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Ben Pfaff July 9, 2018, 6:34 p.m. UTC | #2
I think you're right.

On Mon, Jul 09, 2018 at 11:04:03AM -0700, Yifeng Sun wrote:
> I think the correct fix may be as follows, do you mind rechecking it?
> Thanks.
> 
> diff --git a/datapath/vport.c b/datapath/vport.c
> index 02f6b56d3243..fcf0fea0a245 100644
> --- a/datapath/vport.c
> +++ b/datapath/vport.c
> @@ -93,7 +93,6 @@ int ovs_vport_init(void)
>                 goto err_stt;
> 
>         return 0;
> -       ovs_stt_cleanup_module();
>  err_stt:
>         vxlan_cleanup_module();
>  err_vxlan:
> 
> On Mon, Jul 9, 2018 at 6:09 AM, Alin Gabriel Serdean <aserdean@ovn.org>
> wrote:
> 
> > The line "ovs_stt_cleanup_module();" was unreachable. Looking
> > at the rest of the goto labels they also seem wrong, so fix them also.
> >
> > Found using static analysis tools.
> >
> > Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
> > ---
> >  datapath/vport.c | 17 +++++++++--------
> >  1 file changed, 9 insertions(+), 8 deletions(-)
> >
> > diff --git a/datapath/vport.c b/datapath/vport.c
> > index 02f6b56d3..5f11dd6ad 100644
> > --- a/datapath/vport.c
> > +++ b/datapath/vport.c
> > @@ -93,22 +93,23 @@ int ovs_vport_init(void)
> >                 goto err_stt;
> >
> >         return 0;
> > -       ovs_stt_cleanup_module();
> > +
> >  err_stt:
> > -       vxlan_cleanup_module();
> > +       ovs_stt_cleanup_module();
> >  err_vxlan:
> > -       geneve_cleanup_module();
> > +       vxlan_cleanup_module();
> >  err_geneve:
> > -       ip6_tunnel_cleanup();
> > +       geneve_cleanup_module();
> >  err_ip6_tunnel:
> > -       ip6gre_fini();
> > +       ip6_tunnel_cleanup();
> >  err_ip6gre:
> > -       ipgre_fini();
> > +       ip6gre_fini();
> >  err_ipgre:
> > -       gre_exit();
> > +       ipgre_fini();
> >  err_gre:
> > -       lisp_cleanup_module();
> > +       gre_exit();
> >  err_lisp:
> > +       lisp_cleanup_module();
> >         kfree(dev_table);
> >         return err;
> >  }
> > --
> > 2.16.1.windows.1
> >
> > _______________________________________________
> > dev mailing list
> > dev@openvswitch.org
> > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> >
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Alin Serdean July 19, 2018, 6:36 p.m. UTC | #3
> Subiect: Re: [ovs-dev] [PATCH 2/2] Datapath: Fix ovs_vport_init unreachable
> code and goto labels
> 
> I think the correct fix may be as follows, do you mind rechecking it?
> Thanks.
> 
> diff --git a/datapath/vport.c b/datapath/vport.c index
> 02f6b56d3243..fcf0fea0a245 100644
> --- a/datapath/vport.c
> +++ b/datapath/vport.c
> @@ -93,7 +93,6 @@ int ovs_vport_init(void)
>                 goto err_stt;
> 
>         return 0;
> -       ovs_stt_cleanup_module();
>  err_stt:
>         vxlan_cleanup_module();
>  err_vxlan:
> 
Thanks for the suggestion. I folded in the changes and sent out a v2:
https://patchwork.ozlabs.org/patch/946556/
Do you mind giving a Signed-off?
diff mbox series

Patch

diff --git a/datapath/vport.c b/datapath/vport.c
index 02f6b56d3..5f11dd6ad 100644
--- a/datapath/vport.c
+++ b/datapath/vport.c
@@ -93,22 +93,23 @@  int ovs_vport_init(void)
 		goto err_stt;
 
 	return 0;
-	ovs_stt_cleanup_module();
+
 err_stt:
-	vxlan_cleanup_module();
+	ovs_stt_cleanup_module();
 err_vxlan:
-	geneve_cleanup_module();
+	vxlan_cleanup_module();
 err_geneve:
-	ip6_tunnel_cleanup();
+	geneve_cleanup_module();
 err_ip6_tunnel:
-	ip6gre_fini();
+	ip6_tunnel_cleanup();
 err_ip6gre:
-	ipgre_fini();
+	ip6gre_fini();
 err_ipgre:
-	gre_exit();
+	ipgre_fini();
 err_gre:
-	lisp_cleanup_module();
+	gre_exit();
 err_lisp:
+	lisp_cleanup_module();
 	kfree(dev_table);
 	return err;
 }