net: stmmac: dwmac-sun8i: Fix probe error handling
authorSamuel Holland <samuel@sholland.org>
Sun, 3 Jan 2021 11:17:41 +0000 (05:17 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Jan 2021 13:16:54 +0000 (14:16 +0100)
commit413a79ccb98e9bf1c9d4b25b26c92d7d16be5e72
tree460c2ba81cdf2ed7aa08c522108a2ba07a3ef085
parent8d12c062ca995de6c3124d42d5d96c1ff9da4936
net: stmmac: dwmac-sun8i: Fix probe error handling

[ Upstream commit 7eeecc4b1f480c7ba1932cb9a7693f8c452640f2 ]

stmmac_pltfr_remove does three things in one function, making it
inapproprate for unwinding the steps in the probe function. Currently,
a failure before the call to stmmac_dvr_probe would leak OF node
references due to missing a call to stmmac_remove_config_dt. And an
error in stmmac_dvr_probe would cause the driver to attempt to remove a
netdevice that was never added. Fix these by reordering the init and
splitting out the error handling steps.

Fixes: 9f93ac8d4085 ("net-next: stmmac: Add dwmac-sun8i")
Fixes: 40a1dcee2d18 ("net: ethernet: dwmac-sun8i: Use the correct function in exit path")
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c