diff mbox series

[net] dpaa2-eth: free already allocated channels on probe defer

Message ID 1573465255-31409-1-git-send-email-ioana.ciornei@nxp.com
State Not Applicable
Delegated to: David Miller
Headers show
Series [net] dpaa2-eth: free already allocated channels on probe defer | expand

Commit Message

Ioana Ciornei Nov. 11, 2019, 9:40 a.m. UTC
The setup_dpio() function tries to allocate a number of channels equal
to the number of CPUs online. When there are no enough DPCON objects
already probed, the function will return EPROBE_DEFER. When this
happens, the already allocated channels are not freed. This results in
the incapacity of properly probing the next time around.
Fix this by freeing the channels on the error path.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

David Miller Nov. 12, 2019, 6:01 a.m. UTC | #1
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Mon, 11 Nov 2019 11:40:55 +0200

> The setup_dpio() function tries to allocate a number of channels equal
> to the number of CPUs online. When there are no enough DPCON objects
> already probed, the function will return EPROBE_DEFER. When this
> happens, the already allocated channels are not freed. This results in
> the incapacity of properly probing the next time around.
> Fix this by freeing the channels on the error path.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Please add an appropriate Fixes: tag and resubmit.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 19379bae0144..22e9519f65bb 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -2232,6 +2232,14 @@  static int setup_dpio(struct dpaa2_eth_priv *priv)
 err_service_reg:
 	free_channel(priv, channel);
 err_alloc_ch:
+	for (i = 0; i < priv->num_channels; i++) {
+		channel = priv->channel[i];
+		nctx = &channel->nctx;
+		dpaa2_io_service_deregister(channel->dpio, nctx, dev);
+		free_channel(priv, channel);
+	}
+	priv->num_channels = 0;
+
 	if (err == -EPROBE_DEFER)
 		return err;