Commit 451321d6 authored by Michael Ellerman's avatar Michael Ellerman Committed by Linus Torvalds

[PATCH] ppc64: make HvLpEvent_unregisterHandler() work

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 first patch, which makes HvLpEvent_unregisterHandler() work.
Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f1c5697d
......@@ -34,10 +34,18 @@ int HvLpEvent_registerHandler( HvLpEvent_Type eventType, LpEventHandler handler
int HvLpEvent_unregisterHandler( HvLpEvent_Type eventType )
{
int rc = 1;
might_sleep();
if ( eventType < HvLpEvent_Type_NumTypes ) {
if ( !lpEventHandlerPaths[eventType] ) {
lpEventHandler[eventType] = NULL;
rc = 0;
/* We now sleep until all other CPUs have scheduled. This ensures that
* the deletion is seen by all other CPUs, and that the deleted handler
* isn't still running on another CPU when we return. */
synchronize_kernel();
}
}
return rc;
......
......@@ -75,6 +75,9 @@ typedef void (*LpEventHandler)(struct HvLpEvent *, struct pt_regs *);
extern int HvLpEvent_registerHandler( HvLpEvent_Type eventType, LpEventHandler hdlr);
// Unregister a handler for an event type
// This call will sleep until the handler being removed is guaranteed to
// be no longer executing on any CPU. Do not call with locks held.
//
// returns 0 on success
// Unregister will fail if there are any paths open for the type
extern int HvLpEvent_unregisterHandler( HvLpEvent_Type eventType );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment