Re: [PATCH] Fix release function in IPMI device model
From: Russell King
Date: Wed Mar 22 2006 - 14:21:06 EST
On Wed, Mar 22, 2006 at 09:57:42AM -0600, Corey Minyard wrote:
> @@ -1800,7 +1802,7 @@ static struct bmc_device *ipmi_find_bmc_
> static void ipmi_bmc_release(struct device *dev)
> - printk(KERN_DEBUG "ipmi_bmc release\n");
> + kfree(to_bmc_device(to_platform_device(dev)));
> static ssize_t device_id_show(struct device *dev,
Okay, so the release function is in the same module as the code which
is unregistering it. No, wrong.
What this means is that if you rmmod this module, but userspace has
some file associated with the platform device still open, and then it
drops that refcount, your release function will be called.
But wait, the module code has been unmapped. Instant oops.
Use the additions to the platform device API to sanely handle platform
devices, and don't try to wrap a platform device up into some other
There's comments on lkml about this additional platform device API
(search for platform_device_alloc) or in the git commit comments.
I don't have any references to either to hand, sorry.
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/