Re: more on module usage count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 19 Aug 2003 15:04:48 +0200
"Angelo Dell'Aera" <buffer@antifork.org> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> I was looking at the source of one of the NIC drivers which triggers a
> kernel  panic  when  removed  while  generating traffic  and  maybe  I
> realized  what should  be  the cause  of  it. I'm  referring to  3c509
> driver. Taking a look at the cleanup routine
> 
> 
> static void __exit el3_cleanup_module(void)
> {
>     struct net_device *next_dev;
> 
>     while (el3_root_dev) {
>         struct el3_private *lp = (struct el3_private *)el3_root_dev->priv;
> 
>         next_dev = lp->next_dev;
>         el3_common_remove (el3_root_dev);
>         el3_root_dev = next_dev;
>     }
>     [..]
> 
> 
> static void el3_common_remove (struct net_device *dev)
> {
>         struct el3_private *lp = dev->priv;
> 
>         (void) lp;              /* Keep gcc quiet... */
> #ifdef CONFIG_PM
>         if (lp->pmdev)
>             pm_unregister(lp->pmdev);
> #endif
> #if defined(__ISAPNP__) && !defined(CONFIG_X86_PC9800)
>         if (lp->type == EL3_PNP)
>             pnp_device_detach(to_pnp_dev(lp->dev));
> #endif
> 
>         unregister_netdev (dev);
>         release_region(dev->base_addr, EL3_IO_EXTENT);
>         kfree (dev);
> }
> 
> 
> If a user doesn't shut  down the interface before removing the module,
> it's easy to  realize that some problems could occur.  First of all, I
> think that before calling  el3_common_remove() in the cleanup routine,
> it could be safer to call a netif_stop_queue() on the net device to be
> removed. Then,  after the while loop,  I think we should  take care of
> releasing the IRQ.
> 

If user hasn't shutdown the device then unregister_netdev does 
the shutdown itself by calling dev_close -> el3_close -> el3_down.

The problem may be that the el3_down routine needs to wait till the
receiver has completed shutting down, or check for packets in flight
on transmit.  Shutting off receiver and transmitter are chip dependant
and there may be issues doing it when chip is busy.

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux