Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dpaa2-eth: free already allocated channels on probe defer

The setup_dpio() function tries to allocate a number of channels equal
to the number of CPUs online. When there are not 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.

Fixes: d7f5a9d89a55 ("dpaa2-eth: defer probe on object allocate")
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ioana Ciornei and committed by
David S. Miller
5aa4277d 6d6dd528

+9 -1
+9 -1
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
··· 2232 2232 err_service_reg: 2233 2233 free_channel(priv, channel); 2234 2234 err_alloc_ch: 2235 - if (err == -EPROBE_DEFER) 2235 + if (err == -EPROBE_DEFER) { 2236 + for (i = 0; i < priv->num_channels; i++) { 2237 + channel = priv->channel[i]; 2238 + nctx = &channel->nctx; 2239 + dpaa2_io_service_deregister(channel->dpio, nctx, dev); 2240 + free_channel(priv, channel); 2241 + } 2242 + priv->num_channels = 0; 2236 2243 return err; 2244 + } 2237 2245 2238 2246 if (cpumask_empty(&priv->dpio_cpumask)) { 2239 2247 dev_err(dev, "No cpu with an affine DPIO/DPCON\n");