From: Arina Kharlamova <arin…@mbzuai.ac.ae>
sonic_probe1() reserves the register area with request_mem_region(),
but the error paths of sonic_probe1() and xtsonic_probe() and
xtsonic_device_remove() release it with release_region(). That looks
the range up in the I/O port resource tree, where it was never
inserted, so __release_region() prints "Trying to free nonexistent
resource" and the memory region stays reserved. The next probe of the
device then fails with -EBUSY.
sonic_probe1() also returns -ENODEV without releasing the region when
the silicon revision is not a known one.
Use release_mem_region() in all three places and leave through the
existing error label when the revision check fails.
Fixes: 74f2a5f0ef64 ("xtensa: Add support for the Sonic Ethernet device for the XT2000 board.")
Signed-off-by: Arina Kharlamova <arin…@mbzuai.ac.ae>
---
drivers/net/ethernet/natsemi/xtsonic.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/natsemi/xtsonic.c b/drivers/net/ethernet/natsemi/xtsonic.c
index ca229c688a71..d727bf3eae76 100644
--- a/drivers/net/ethernet/natsemi/xtsonic.c
+++ b/drivers/net/ethernet/natsemi/xtsonic.c
@@ -146,7 +146,8 @@ static int sonic_probe1(struct net_device *dev)
if (known_revisions[i] == 0xffff) {
pr_info("SONIC ethernet controller not found (0x%4x)\n",
silicon_revision);
- return -ENODEV;
+ err = -ENODEV;
+ goto out;
}
/*
@@ -187,7 +188,7 @@ static int sonic_probe1(struct net_device *dev)
return 0;
out:
- release_region(dev->base_addr, SONIC_MEM_SIZE);
+ release_mem_region(dev->base_addr, SONIC_MEM_SIZE);
return err;
}
@@ -238,7 +239,7 @@ undo_probe1:
dma_free_coherent(lp->device,
SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
lp->descriptors, lp->descriptors_laddr);
- release_region(dev->base_addr, SONIC_MEM_SIZE);
+ release_mem_region(dev->base_addr, SONIC_MEM_SIZE);
out:
free_netdev(dev);
@@ -258,7 +259,7 @@ static void xtsonic_device_remove(struct platform_device *pdev)
dma_free_coherent(lp->device,
SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
lp->descriptors, lp->descriptors_laddr);
- release_region (dev->base_addr, SONIC_MEM_SIZE);
+ release_mem_region(dev->base_addr, SONIC_MEM_SIZE);
free_netdev(dev);
}
--
Git-157)