Commit 67c2fb8f authored by Anton Vorontsov's avatar Anton Vorontsov Committed by David S. Miller

ucc_geth: Fix IRQ freeing code in ucc_geth_open()

open() routine calls stop() in case of errors, the function will try
to free the requested IRQ. But we don't know if it was actually
requested, so the code might issue bogus free_irq(0, dev) call.

Fix this by rearranging the code so that now request_irq() is the last
call in the open() routine, and move free_irq() into the close().
Signed-off-by: default avatarAnton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1762a29a
...@@ -2300,8 +2300,6 @@ static void ucc_geth_stop(struct ucc_geth_private *ugeth) ...@@ -2300,8 +2300,6 @@ static void ucc_geth_stop(struct ucc_geth_private *ugeth)
tempval &= ~(MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX); tempval &= ~(MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
out_be32(&ug_regs->maccfg1, tempval); out_be32(&ug_regs->maccfg1, tempval);
free_irq(ugeth->ug_info->uf_info.irq, ugeth->dev);
ucc_geth_memclean(ugeth); ucc_geth_memclean(ugeth);
} }
...@@ -3759,21 +3757,20 @@ static int ucc_geth_open(struct net_device *dev) ...@@ -3759,21 +3757,20 @@ static int ucc_geth_open(struct net_device *dev)
phy_start(ugeth->phydev); phy_start(ugeth->phydev);
err = err = ugeth_enable(ugeth, COMM_DIR_RX_AND_TX);
request_irq(ugeth->ug_info->uf_info.irq, ucc_geth_irq_handler, 0,
"UCC Geth", dev);
if (err) { if (err) {
if (netif_msg_ifup(ugeth)) if (netif_msg_ifup(ugeth))
ugeth_err("%s: Cannot get IRQ for net device, aborting.", ugeth_err("%s: Cannot enable net device, aborting.", dev->name);
dev->name);
ucc_geth_stop(ugeth); ucc_geth_stop(ugeth);
goto out_err; goto out_err;
} }
err = ugeth_enable(ugeth, COMM_DIR_RX_AND_TX); err = request_irq(ugeth->ug_info->uf_info.irq, ucc_geth_irq_handler,
0, "UCC Geth", dev);
if (err) { if (err) {
if (netif_msg_ifup(ugeth)) if (netif_msg_ifup(ugeth))
ugeth_err("%s: Cannot enable net device, aborting.", dev->name); ugeth_err("%s: Cannot get IRQ for net device, aborting.",
dev->name);
ucc_geth_stop(ugeth); ucc_geth_stop(ugeth);
goto out_err; goto out_err;
} }
...@@ -3799,6 +3796,8 @@ static int ucc_geth_close(struct net_device *dev) ...@@ -3799,6 +3796,8 @@ static int ucc_geth_close(struct net_device *dev)
ucc_geth_stop(ugeth); ucc_geth_stop(ugeth);
free_irq(ugeth->ug_info->uf_info.irq, ugeth->dev);
phy_disconnect(ugeth->phydev); phy_disconnect(ugeth->phydev);
ugeth->phydev = NULL; ugeth->phydev = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment