aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/aoe
diff options
context:
space:
mode:
authorEd Cashin <ecashin@coraid.com>2012-10-04 20:16:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-05 14:05:27 -0400
commit1b86fda9adf1b691a76f8ceddfc59d0c8386257c (patch)
treeda4fcaa9696231ff7bd84b0614706aefca7d7d6c /drivers/block/aoe
parent64a80f5ac78a289f66c373ace61973205d960ee7 (diff)
aoe: increase net_device reference count while using it
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>
Diffstat (limited to 'drivers/block/aoe')
-rw-r--r--drivers/block/aoe/aoecmd.c4
-rw-r--r--drivers/block/aoe/aoedev.c7
2 files changed, 11 insertions, 0 deletions
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index cc692fee7ce1..2f19b9bba913 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -494,12 +494,15 @@ static void
494ejectif(struct aoetgt *t, struct aoeif *ifp) 494ejectif(struct aoetgt *t, struct aoeif *ifp)
495{ 495{
496 struct aoeif *e; 496 struct aoeif *e;
497 struct net_device *nd;
497 ulong n; 498 ulong n;
498 499
500 nd = ifp->nd;
499 e = t->ifs + NAOEIFS - 1; 501 e = t->ifs + NAOEIFS - 1;
500 n = (e - ifp) * sizeof *ifp; 502 n = (e - ifp) * sizeof *ifp;
501 memmove(ifp, ifp+1, n); 503 memmove(ifp, ifp+1, n);
502 e->nd = NULL; 504 e->nd = NULL;
505 dev_put(nd);
503} 506}
504 507
505static int 508static int
@@ -1317,6 +1320,7 @@ setifbcnt(struct aoetgt *t, struct net_device *nd, int bcnt)
1317 pr_err("aoe: device setifbcnt failure; too many interfaces.\n"); 1320 pr_err("aoe: device setifbcnt failure; too many interfaces.\n");
1318 return; 1321 return;
1319 } 1322 }
1323 dev_hold(nd);
1320 p->nd = nd; 1324 p->nd = nd;
1321 p->bcnt = bcnt; 1325 p->bcnt = bcnt;
1322 } 1326 }
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 3968fe6c0077..6be7b3858340 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -295,6 +295,13 @@ freetgt(struct aoedev *d, struct aoetgt *t)
295{ 295{
296 struct frame *f; 296 struct frame *f;
297 struct list_head *pos, *nx, *head; 297 struct list_head *pos, *nx, *head;
298 struct aoeif *ifp;
299
300 for (ifp = t->ifs; ifp < &t->ifs[NAOEIFS]; ++ifp) {
301 if (!ifp->nd)
302 break;
303 dev_put(ifp->nd);
304 }
298 305
299 head = &t->ffree; 306 head = &t->ffree;
300 list_for_each_safe(pos, nx, head) { 307 list_for_each_safe(pos, nx, head) {