From: ben-linux@fluff.org (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: Using statically allocated memory for platform_data.
Date: Mon, 2 Nov 2009 15:52:31 +0000 [thread overview]
Message-ID: <20091102155231.GC20341@fluff.org.uk> (raw)
In-Reply-To: <20091102152500.GD23772@trinity.fluff.org>
On Mon, Nov 02, 2009 at 03:25:00PM +0000, Ben Dooks wrote:
> On Mon, Nov 02, 2009 at 03:05:25PM +0000, Russell King - ARM Linux wrote:
> > On Mon, Nov 02, 2009 at 03:00:11PM +0000, Ben Dooks wrote:
> > > This looks like something is freeing stuff that it did not allocate in
> > > the first place, which is IMHO bad. The call platform_device_alloc()
> > > is setting platform_device_release() as the default release function
> > > but platform_device_release() releases more than platform_device_alloc()
> > > actually created.
> > >
> > > My view is that platform_device_alloc()'s default release shouldn't
> > > be freeing the platform data, and that using platform_device_add_data()
> > > or platform_device_add_resources() should change either the behvaiour
> > > of platform_device_release() or it should change the pointer to a new
> > > release function.
> >
> > That doesn't work - how do those other functions (adding) know what data
> > has also been added by other functions? That can't work reliably.
>
> You could wrapper platform device, and each of the add functions could
> update it, but that would assume the platform device had been allocated
> with platform_device_alloc().
Having had a look, all the current users of platform_device_add_data()
are from a platform_alloc_device() created device.
The number of calls to platform_device_add_resources() are many, but
the ones I checked are from platform_alloc_device().
However your point being that these add calls may not be used on a
device that has been created from platform_device_alloc() is one I
overlooked.
Having a state machine that changed the release call from
platform_device_release() to say platform_device_release_resources()
or platform_device_release_all() and then platform_device_release_all()
may be another way to do it.
--
Ben (ben at fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
WARNING: multiple messages have this Message-ID (diff)
From: Ben Dooks <ben-linux@fluff.org>
To: Ben Dooks <ben-linux@fluff.org>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>,
Antonio Ospite <ospite@studenti.unina.it>,
openezx-devel@lists.openezx.org,
Samuel Ortiz <sameo@linux.intel.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Mike Rapoport <mike@compulab.co.il>,
Daniel Ribeiro <drwyrm@gmail.com>
Subject: Re: Using statically allocated memory for platform_data.
Date: Mon, 2 Nov 2009 15:52:31 +0000 [thread overview]
Message-ID: <20091102155231.GC20341@fluff.org.uk> (raw)
In-Reply-To: <20091102152500.GD23772@trinity.fluff.org>
On Mon, Nov 02, 2009 at 03:25:00PM +0000, Ben Dooks wrote:
> On Mon, Nov 02, 2009 at 03:05:25PM +0000, Russell King - ARM Linux wrote:
> > On Mon, Nov 02, 2009 at 03:00:11PM +0000, Ben Dooks wrote:
> > > This looks like something is freeing stuff that it did not allocate in
> > > the first place, which is IMHO bad. The call platform_device_alloc()
> > > is setting platform_device_release() as the default release function
> > > but platform_device_release() releases more than platform_device_alloc()
> > > actually created.
> > >
> > > My view is that platform_device_alloc()'s default release shouldn't
> > > be freeing the platform data, and that using platform_device_add_data()
> > > or platform_device_add_resources() should change either the behvaiour
> > > of platform_device_release() or it should change the pointer to a new
> > > release function.
> >
> > That doesn't work - how do those other functions (adding) know what data
> > has also been added by other functions? That can't work reliably.
>
> You could wrapper platform device, and each of the add functions could
> update it, but that would assume the platform device had been allocated
> with platform_device_alloc().
Having had a look, all the current users of platform_device_add_data()
are from a platform_alloc_device() created device.
The number of calls to platform_device_add_resources() are many, but
the ones I checked are from platform_alloc_device().
However your point being that these add calls may not be used on a
device that has been created from platform_device_alloc() is one I
overlooked.
Having a state machine that changed the release call from
platform_device_release() to say platform_device_release_resources()
or platform_device_release_all() and then platform_device_release_all()
may be another way to do it.
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
next prev parent reply other threads:[~2009-11-02 15:52 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-02 10:23 Using statically allocated memory for platform_data Antonio Ospite
2009-11-02 10:23 ` Antonio Ospite
2009-11-02 10:39 ` Uwe Kleine-König
2009-11-02 10:39 ` Uwe Kleine-König
2009-11-02 14:51 ` Ben Dooks
2009-11-02 14:51 ` Ben Dooks
2009-11-02 15:00 ` Ben Dooks
2009-11-02 15:00 ` Ben Dooks
2009-11-02 15:05 ` Russell King - ARM Linux
2009-11-02 15:05 ` Russell King - ARM Linux
2009-11-02 15:25 ` Ben Dooks
2009-11-02 15:25 ` Ben Dooks
2009-11-02 15:52 ` Ben Dooks [this message]
2009-11-02 15:52 ` Ben Dooks
2009-11-02 15:56 ` Russell King - ARM Linux
2009-11-02 15:56 ` Russell King - ARM Linux
2009-11-02 16:28 ` Ben Dooks
2009-11-02 16:28 ` Ben Dooks
2009-11-02 16:37 ` Russell King - ARM Linux
2009-11-02 16:37 ` Russell King - ARM Linux
2009-11-02 16:47 ` Ben Dooks
2009-11-02 16:47 ` Ben Dooks
2009-11-03 17:31 ` Antonio Ospite
2009-11-03 17:31 ` Antonio Ospite
2009-11-08 21:24 ` Antonio Ospite
2009-11-08 21:24 ` Antonio Ospite
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=20091102155231.GC20341@fluff.org.uk \
--to=ben-linux@fluff.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.