mlxsw: spectrum_router: Fix error path in mlxsw_sp_router_init
authorJiri Pirko <jiri@mellanox.com>
Thu, 8 Sep 2016 06:16:01 +0000 (08:16 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 Sep 2016 23:56:53 +0000 (16:56 -0700)
When neigh_init fails, we have to do proper cleanup including
router_fini call.

Fixes: 6cf3c971dc84cb ("mlxsw: spectrum_router: Add private neigh table")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 352259b3c38a87e77259b663a552ed749629aa4d..3f5c51da6d3e9d8304c21d69b165ae9dc96bcf55 100644 (file)
@@ -1517,7 +1517,14 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
                return err;
        mlxsw_sp_lpm_init(mlxsw_sp);
        mlxsw_sp_vrs_init(mlxsw_sp);
-       return mlxsw_sp_neigh_init(mlxsw_sp);
+       err = mlxsw_sp_neigh_init(mlxsw_sp);
+       if (err)
+               goto err_neigh_init;
+       return 0;
+
+err_neigh_init:
+       __mlxsw_sp_router_fini(mlxsw_sp);
+       return err;
 }
 
 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp)