[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20091102145139.GA20341@fluff.org.uk>
Date: Mon, 2 Nov 2009 14:51:39 +0000
From: Ben Dooks <ben-linux@...ff.org>
To: Uwe Kleine-K?nig <u.kleine-koenig@...gutronix.de>
Cc: Antonio Ospite <ospite@...denti.unina.it>,
linux-arm-kernel@...ts.infradead.org,
openezx-devel@...ts.openezx.org, linux-kernel@...r.kernel.org,
Samuel Ortiz <sameo@...ux.intel.com>,
Daniel Ribeiro <drwyrm@...il.com>,
Mike Rapoport <mike@...pulab.co.il>
Subject: Re: Using statically allocated memory for platform_data.
On Mon, Nov 02, 2009 at 11:39:40AM +0100, Uwe Kleine-K?nig wrote:
> Hello,
>
> On Mon, Nov 02, 2009 at 11:23:16AM +0100, Antonio Ospite wrote:
> > Hi,
> >
> > I noted that in some mfd drivers (drivers/mfd/ezx-pcap.c and
> > drivers/mfd/da903x.c) there is code like this:
> >
> > static int __devinit pcap_add_subdev(struct pcap_chip *pcap,
> > struct pcap_subdev *subdev)
> > {
> > struct platform_device *pdev;
> >
> > pdev = platform_device_alloc(subdev->name, subdev->id);
> > pdev->dev.parent = &pcap->spi->dev;
> > pdev->dev.platform_data = subdev->platform_data;
> >
> > return platform_device_add(pdev);
> > }
> >
> > Note the _direct_assignment_ of platform data; then in board init code
> > there are often global struct pointers passed as subdev platform data,
> > see arch/arm/mach-pxa/em-x270.c::em_x270_da9030_subdevs for instance.
> >
> > In these cases, whenever the subdev platform device is unregistered,
> > the call to platform_device_release() tries to kfree the platform data,
> > and being it statically allocated memory this triggers a bug from SLAB:
> > kernel BUG at mm/slab.c:521!
> > In my case this prevented proper device poweroff.
> >
> > The question: should these mfd drivers use platform_device_add_data()
> > which allocates dynamic memory for *a copy* of platform data? Is this
> > simple solution acceptable even if there will be more memory used?
> If you move the original data lives in .init there is no duplication.
they you can't modprobe devices after loading the kernel, so udev
autoload and the like become impossible.
--
Ben (ben@...ff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists