Message ID | 20230313224237.28757-8-Sergey.Semin@baikalelectronics.ru (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: stmmac: Fixes bundle #1 | expand |
On Tue, Mar 14, 2023 at 01:42:31AM +0300, Serge Semin wrote: > Indeed in accordance with the alloc_dma_desc_resources() method logic the > Rx descriptors will be left allocated if Tx descriptors allocation fails. > Fix it by calling the free_dma_rx_desc_resources() in case if the > alloc_dma_tx_desc_resources() method returns non-zero value. > > While at it refactor the method a bit. Just move the Rx descriptors > allocation method invocation out of the local variables declaration block > and discard a pointless comment from there. > LGTM, Thanks. Reviewed-by: Piotr Raczynski <piotr.raczynski@intel.com> > Fixes: 71fedb0198cb ("net: stmmac: break some functions into RX and TX scopes") > Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index 4d643b1bbf65..229f827d7572 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -2182,13 +2182,15 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv, > static int alloc_dma_desc_resources(struct stmmac_priv *priv, > struct stmmac_dma_conf *dma_conf) > { > - /* RX Allocation */ > - int ret = alloc_dma_rx_desc_resources(priv, dma_conf); > + int ret; > > + ret = alloc_dma_rx_desc_resources(priv, dma_conf); > if (ret) > return ret; > > ret = alloc_dma_tx_desc_resources(priv, dma_conf); > + if (ret) > + free_dma_rx_desc_resources(priv, dma_conf); > > return ret; > } > -- > 2.39.2 > >
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4d643b1bbf65..229f827d7572 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2182,13 +2182,15 @@ static int alloc_dma_tx_desc_resources(struct stmmac_priv *priv, static int alloc_dma_desc_resources(struct stmmac_priv *priv, struct stmmac_dma_conf *dma_conf) { - /* RX Allocation */ - int ret = alloc_dma_rx_desc_resources(priv, dma_conf); + int ret; + ret = alloc_dma_rx_desc_resources(priv, dma_conf); if (ret) return ret; ret = alloc_dma_tx_desc_resources(priv, dma_conf); + if (ret) + free_dma_rx_desc_resources(priv, dma_conf); return ret; }
Indeed in accordance with the alloc_dma_desc_resources() method logic the Rx descriptors will be left allocated if Tx descriptors allocation fails. Fix it by calling the free_dma_rx_desc_resources() in case if the alloc_dma_tx_desc_resources() method returns non-zero value. While at it refactor the method a bit. Just move the Rx descriptors allocation method invocation out of the local variables declaration block and discard a pointless comment from there. Fixes: 71fedb0198cb ("net: stmmac: break some functions into RX and TX scopes") Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)