mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ed Cashin <ecashin@coraid.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, ecashin@coraid.com
Subject: [PATCH 10/14] aoe: increase net_device reference count while using it
Date: Tue, 21 Aug 2012 11:07:43 -0400	[thread overview]
Message-ID: <3e100231f8a6be2e831214fc9db8a9226ddc8316.1345743802.git.ecashin@coraid.com> (raw)
In-Reply-To: <cover.1345743800.git.ecashin@coraid.com>

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>
---
 drivers/block/aoe/aoecmd.c |    4 ++++
 drivers/block/aoe/aoedev.c |    7 +++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index fec28738..c985b50 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -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
@@ -1325,6 +1328,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;
 	}
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 3968fe6..6be7b38 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -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) {
-- 
1.7.2.5


  parent reply	other threads:[~2012-08-23 18:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-23 17:43 [PATCH 00/14] aoe driver v49 performance and usability improvements Ed Cashin
2012-08-18  1:18 ` [PATCH 01/14] aoe: for performance support larger packet payloads Ed Cashin
2012-08-23 20:32   ` Ed Cashin
2012-08-24 21:11   ` Andrew Morton
2012-08-18  1:24 ` [PATCH 02/14] aoe: kernel thread handles I/O completions for simple locking Ed Cashin
2012-08-24 21:22   ` Andrew Morton
2012-08-25  0:35     ` Ed Cashin
2012-08-26  1:31     ` ecashin
2012-08-18  1:26 ` [PATCH 03/14] aoe: become I/O request queue handler for increased user control Ed Cashin
2012-08-18  1:26 ` [PATCH 04/14] aoe: use a kernel thread for transmissions Ed Cashin
2012-08-18  1:27 ` [PATCH 05/14] aoe: use packets that work with the smallest-MTU local interface Ed Cashin
2012-08-18  1:27 ` [PATCH 06/14] aoe: failover remote interface based on aoe_deadsecs parameter Ed Cashin
2012-08-18  1:27 ` [PATCH 07/14] aoe: do revalidation steps in order Ed Cashin
2012-08-18  1:27 ` [PATCH 08/14] aoe: disallow unsupported AoE minor addresses Ed Cashin
2012-08-18  1:27 ` [PATCH 11/14] aoe: remove unused code and add cosmetic improvements Ed Cashin
2012-08-18  1:28 ` [PATCH 12/14] aoe: update internal version number to 49 Ed Cashin
2012-08-18  1:28 ` [PATCH 13/14] aoe: update copyright year in touched files Ed Cashin
2012-08-21 14:58 ` [PATCH 09/14] aoe: associate frames with the AoE storage target Ed Cashin
2012-08-21 15:07 ` Ed Cashin [this message]
2012-08-23 17:36 ` [PATCH 14/14] aoe: update documentation with new URL and VM settings reference Ed Cashin
2012-08-24 23:57 ` [PATCH 00/14] aoe driver v49 performance and usability improvements Ed Cashin
2012-08-28 12:53 Ed Cashin
2012-08-25 14:39 ` [PATCH 10/14] aoe: increase net_device reference count while using it Ed Cashin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e100231f8a6be2e831214fc9db8a9226ddc8316.1345743802.git.ecashin@coraid.com \
    --to=ecashin@coraid.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®