From: Michael Ellerman <michael@ellerman.id.au>
To: akpm@osdl.org
Cc: paulus@au1.ibm.com, linux-kernel@vger.kernel.org,
linuxppc64-dev@ozlabs.org
Subject: [PATCH 2/2] ppc64: Fix iseries_veth module unload race and memory leak
Date: Tue, 11 Jan 2005 19:43:57 +1100 [thread overview]
Message-ID: <20050111084358.0ABD917DF7@ozlabs.au.ibm.com> (raw)
Hi All,
When the iseries_veth driver module is unloaded there is the potential for an
oops and also some memory leakage.
Because the HvLpEvent_unregisterHandler() function did no synchronisation, it
was possible for the handler that was being unregistered to be running on another
CPU *after* HvLpEvent_unregisterHandler() had returned. This could cause the
iseries_veth driver to leave work in the events work queue after the module
had been unloaded. When that work was eventually executed we got an oops.
In addition some of the data structures in the iseries_veth driver were not
being correctly freed when the module was unloaded.
This is the second patch, we make iseries_veth call flush_scheduled_work()
after we are sure the handler is no longer running, and also fix the memory leaks.
iseries_veth.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
diff -urN 2.6.10-ppc64-stock/drivers/net/iseries_veth.c 2.6.10-ppc64-work/drivers/net/iseries_veth.c
--- 2.6.10-ppc64-stock/drivers/net/iseries_veth.c 2004-12-25 10:14:43.000000000 +1100
+++ 2.6.10-ppc64-work/drivers/net/iseries_veth.c 2005-01-11 18:40:21.811722242 +1100
@@ -642,7 +642,7 @@
return 0;
}
-static void veth_destroy_connection(u8 rlp)
+static void veth_stop_connection(u8 rlp)
{
struct veth_lpar_connection *cnx = veth_cnx[rlp];
@@ -671,9 +671,18 @@
HvLpEvent_Type_VirtualLan,
cnx->num_ack_events,
NULL, NULL);
+}
+
+static void veth_destroy_connection(u8 rlp)
+{
+ struct veth_lpar_connection *cnx = veth_cnx[rlp];
- if (cnx->msgs)
- kfree(cnx->msgs);
+ if (! cnx)
+ return;
+
+ kfree(cnx->msgs);
+ kfree(cnx);
+ veth_cnx[rlp] = NULL;
}
/*
@@ -1375,9 +1384,18 @@
vio_unregister_driver(&veth_driver);
for (i = 0; i < HVMAXARCHITECTEDLPS; ++i)
- veth_destroy_connection(i);
+ veth_stop_connection(i);
HvLpEvent_unregisterHandler(HvLpEvent_Type_VirtualLan);
+
+ /* Hypervisor callbacks may have scheduled more work while we
+ * were destroying connections. Now that we've disconnected from
+ * the hypervisor make sure everything's finished. */
+ flush_scheduled_work();
+
+ for (i = 0; i < HVMAXARCHITECTEDLPS; ++i)
+ veth_destroy_connection(i);
+
}
module_exit(veth_module_cleanup);
reply other threads:[~2005-01-11 8:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20050111084358.0ABD917DF7@ozlabs.au.ibm.com \
--to=michael@ellerman.id.au \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc64-dev@ozlabs.org \
--cc=paulus@au1.ibm.com \
/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®