]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
aoe: increase net_device reference count while using it
authorEd Cashin <ecashin@coraid.com>
Thu, 13 Sep 2012 01:01:35 +0000 (11:01 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 17 Sep 2012 10:46:23 +0000 (20:46 +1000)
This change eliminates the danger that the user could rmmod the driver for
a network interface that is being used for AoE by the aoe driver.

Signed-off-by: Ed Cashin <ecashin@coraid.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/aoe/aoecmd.c
drivers/block/aoe/aoedev.c

index 6529640cbb5e030aaca9b38a51ab3afb31865ac6..16a6cee8782c0952a1b23d7a0b107c945d1841ef 100644 (file)
@@ -493,12 +493,15 @@ static void
 ejectif(struct aoetgt *t, struct aoeif *ifp)
 {
        struct aoeif *e;
+       struct net_device *nd;
        ulong n;
 
+       nd = ifp->nd;
        e = t->ifs + NAOEIFS - 1;
        n = (e - ifp) * sizeof *ifp;
        memmove(ifp, ifp+1, n);
        e->nd = NULL;
+       dev_put(nd);
 }
 
 static int
@@ -1316,6 +1319,7 @@ setifbcnt(struct aoetgt *t, struct net_device *nd, int bcnt)
                        pr_err("aoe: device setifbcnt failure; too many interfaces.\n");
                        return;
                }
+               dev_hold(nd);
                p->nd = nd;
                p->bcnt = bcnt;
        }
index 3968fe6c007730e3b83fe55acab75085febaee8e..6be7b38583403f5ed482bf5ae2e590ba8c87d7d4 100644 (file)
@@ -295,6 +295,13 @@ freetgt(struct aoedev *d, struct aoetgt *t)
 {
        struct frame *f;
        struct list_head *pos, *nx, *head;
+       struct aoeif *ifp;
+
+       for (ifp = t->ifs; ifp < &t->ifs[NAOEIFS]; ++ifp) {
+               if (!ifp->nd)
+                       break;
+               dev_put(ifp->nd);
+       }
 
        head = &t->ffree;
        list_for_each_safe(pos, nx, head) {