Skip to content

Commit

Permalink
aoe: increase net_device reference count while using it
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
ecashin authored and torvalds committed Oct 5, 2012
1 parent 64a80f5 commit 1b86fda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/block/aoe/aoecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,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
Expand Down Expand Up @@ -1317,6 +1320,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;
}
Expand Down
7 changes: 7 additions & 0 deletions drivers/block/aoe/aoedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1b86fda

Please sign in to comment.