.../microchip/sparx5/sparx5_tc_flower.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
Add error handling paths to unwind the PSFP resources that have already
been allocated before returning the error.
Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
---
.../microchip/sparx5/sparx5_tc_flower.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
index 4dc1ebd5d510..e5022d783ee6 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
@@ -807,7 +807,7 @@ static int sparx5_tc_flower_psfp_setup(struct sparx5 *sparx5,
/* Add new flow-meter */
ret = sparx5_psfp_fm_add(sparx5, pol_idx, fm, &psfp_fmid);
if (ret < 0)
- return ret;
+ goto err_sg_del;
}
/* Map stream filter to stream gate */
@@ -816,7 +816,7 @@ static int sparx5_tc_flower_psfp_setup(struct sparx5 *sparx5,
/* Add new stream-filter and map it to a steam gate */
ret = sparx5_psfp_sf_add(sparx5, sf, &psfp_sfid);
if (ret < 0)
- return ret;
+ goto err_fm_del;
/* Streams are classified by ISDX - map ISDX 1:1 to sfid for now. */
sparx5_isdx_conf_set(sparx5, psfp_sfid, psfp_sfid, psfp_fmid);
@@ -824,13 +824,23 @@ static int sparx5_tc_flower_psfp_setup(struct sparx5 *sparx5,
ret = vcap_rule_add_action_bit(vrule, VCAP_AF_ISDX_ADD_REPLACE_SEL,
VCAP_BIT_1);
if (ret)
- return ret;
+ goto err_sf_del;
ret = vcap_rule_add_action_u32(vrule, VCAP_AF_ISDX_VAL, psfp_sfid);
if (ret)
- return ret;
+ goto err_sf_del;
return 0;
+
+err_sf_del:
+ sparx5_isdx_conf_set(sparx5, psfp_sfid, 0, 0);
+ sparx5_psfp_sf_del(sparx5, psfp_sfid);
+err_fm_del:
+ if (pol_idx >= 0)
+ sparx5_psfp_fm_del(sparx5, psfp_fmid);
+err_sg_del:
+ sparx5_psfp_sg_del(sparx5, psfp_sgid);
+ return ret;
}
/* Handle the action trap for a VCAP rule */
--
2.25.1
On Wed, 27 May 2026 15:38:55 +0800 Haoxiang Li wrote: > Add error handling paths to unwind the PSFP resources that have already > been allocated before returning the error. Does not apply, please rebase on https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/ and repost -- pw-bot: cr
On 5/27/2026 12:38 AM, Haoxiang Li wrote: > Add error handling paths to unwind the PSFP resources that have already > been allocated before returning the error. > > Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn> > --- Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> > .../microchip/sparx5/sparx5_tc_flower.c | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c > index 4dc1ebd5d510..e5022d783ee6 100644 > --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c > +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c > @@ -807,7 +807,7 @@ static int sparx5_tc_flower_psfp_setup(struct sparx5 *sparx5, > /* Add new flow-meter */ > ret = sparx5_psfp_fm_add(sparx5, pol_idx, fm, &psfp_fmid); > if (ret < 0) > - return ret; > + goto err_sg_del; > } > > /* Map stream filter to stream gate */ > @@ -816,7 +816,7 @@ static int sparx5_tc_flower_psfp_setup(struct sparx5 *sparx5, > /* Add new stream-filter and map it to a steam gate */ > ret = sparx5_psfp_sf_add(sparx5, sf, &psfp_sfid); > if (ret < 0) > - return ret; > + goto err_fm_del; > > /* Streams are classified by ISDX - map ISDX 1:1 to sfid for now. */ > sparx5_isdx_conf_set(sparx5, psfp_sfid, psfp_sfid, psfp_fmid); > @@ -824,13 +824,23 @@ static int sparx5_tc_flower_psfp_setup(struct sparx5 *sparx5, > ret = vcap_rule_add_action_bit(vrule, VCAP_AF_ISDX_ADD_REPLACE_SEL, > VCAP_BIT_1); > if (ret) > - return ret; > + goto err_sf_del; > > ret = vcap_rule_add_action_u32(vrule, VCAP_AF_ISDX_VAL, psfp_sfid); > if (ret) > - return ret; > + goto err_sf_del; > > return 0; > + > +err_sf_del: > + sparx5_isdx_conf_set(sparx5, psfp_sfid, 0, 0); > + sparx5_psfp_sf_del(sparx5, psfp_sfid); > +err_fm_del: > + if (pol_idx >= 0) > + sparx5_psfp_fm_del(sparx5, psfp_fmid); > +err_sg_del: > + sparx5_psfp_sg_del(sparx5, psfp_sgid); > + return ret; > } > > /* Handle the action trap for a VCAP rule */
© 2016 - 2026 Red Hat, Inc.