Re: [patch 2.6.21-rc5-git 1/2] fix hotplug for legacy platform drivers

From: Russell King
Date: Mon Apr 02 2007 - 06:56:41 EST


On Sat, Mar 31, 2007 at 02:55:38PM -0700, David Brownell wrote:
> --- g26.orig/drivers/pcmcia/pxa2xx_mainstone.c 2007-03-30 16:44:04.000000000 -0700
> +++ g26/drivers/pcmcia/pxa2xx_mainstone.c 2007-03-31 14:23:56.000000000 -0700
> @@ -175,6 +175,8 @@ static int __init mst_pcmcia_init(void)
> if (!mst_pcmcia_device)
> return -ENOMEM;
>
> + /* REVISIT just statically allocate the device */
> + mst_pcmcia_device->dev.uevent_suppress = 0;

Such a comment indicates that you clearly do not understand why these
platform devices are dynamically allocated.

These are modules. If they were statically allocated, then you have a
potential oops waiting to happen if you have the right ordering of user
accesses to sysfs coupled with an inopportune unload of such a driver -
the memory backing the platform device will be unexpectedly released
resulting in an access to freed memory.

The dynamic allocation interfaces for platform devices is there to
allow drivers to properly conform to the sysfs lifetime rules.

Any module statically allocating a device structure is just simply buggy.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
-
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/