[PATCH] ax25 - make sure and hold ref to dev

From: Stephen Hemminger (wwf.nhxrvh@mailit.tunk.net)
Date: Fri Aug 22 2003 - 23:13:28 EEST

  • Next message: Stephen Hemminger: "[RFT][PATCH] ax25 using seq_file"

    The lower layers of ax25 hold a reference to the underlying device
    but don't increment the ref count. This is safe because it does the
    right thing when UNREGISTER notification comes in, but it is better
    to do the right thing.

    I tested this by messing with bpqether and ax25 to make sure
    both can be unloaded correctly.

    diff -Nru a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c
    --- a/net/ax25/ax25_dev.c Fri Aug 22 08:20:46 2003
    +++ b/net/ax25/ax25_dev.c Fri Aug 22 08:20:46 2003
    @@ -67,6 +67,7 @@
     
             dev->ax25_ptr = ax25_dev;
             ax25_dev->dev = dev;
    + dev_hold(dev);
             ax25_dev->forward = NULL;
     
             ax25_dev->values[AX25_VALUES_IPDEFMODE] = AX25_DEF_IPDEFMODE;
    @@ -121,6 +122,7 @@
             if ((s = ax25_dev_list) == ax25_dev) {
                     ax25_dev_list = s->next;
                     spin_unlock_bh(&ax25_dev_lock);
    + dev_put(dev);
                     kfree(ax25_dev);
                     ax25_register_sysctl();
                     return;
    @@ -130,6 +132,7 @@
                     if (s->next == ax25_dev) {
                             s->next = ax25_dev->next;
                             spin_unlock_bh(&ax25_dev_lock);
    + dev_put(dev);
                             kfree(ax25_dev);
                             ax25_register_sysctl();
                             return;
    @@ -196,8 +199,8 @@
             ax25_dev = ax25_dev_list;
             while (ax25_dev != NULL) {
                     s = ax25_dev;
    + dev_put(ax25_dev->dev);
                     ax25_dev = ax25_dev->next;
    -
                     kfree(s);
             }
             ax25_dev_list = NULL;
    -
    To unsubscribe from this list: send the line "unsubscribe linux-hams" in
    the body of a message to hxz@integralaccess.com
    More majordomo info at http://vger.kernel.org/majordomo-info.html



    This archive was generated by hypermail 2b30 : Fri Aug 22 2003 - 23:14:19 EEST