From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: ian <spyro@f2s.com>
Cc: eric miao <eric.y.miao@gmail.com>,
Dmitry Baryshkov <dbaryshkov@gmail.com>,
ARM Linux <linux-arm-kernel@lists.arm.linux.org.uk>,
linux-kernel@vger.kernel.org
Subject: Re: [UPDATED PATCH] Support for Toshiba TMIO multifunction devices
Date: Thu, 22 Nov 2007 00:52:30 +0000 [thread overview]
Message-ID: <20071122005230.GA6170@flint.arm.linux.org.uk> (raw)
In-Reply-To: <1195691649.2329.105.camel@wirenth>
On Thu, Nov 22, 2007 at 12:34:09AM +0000, ian wrote:
> +void mfd_free_devices(struct platform_device *devices, int nr_devs)
> +{
> + struct platform_device *dev = devices;
> + int i;
> +
> + for (i = 0; i < nr_devs; i++) {
> + struct resource *res = dev->resource;
> + platform_device_unregister(dev++);
> + kfree(res);
> + }
> + kfree(devices);
> +}
> +EXPORT_SYMBOL_GPL(mfd_free_devices);
Unfortunately, this is broken as designed (in fact this whole file is.)
I'm not sure why people just don't get it. sysfs. devices. device tree.
It has object lifetime rules. You can _not_ go around unregistering things
and then immediately freeing them - something else might _still_ be using
stuff even after the call to unregister returns.
It's a potential OOPS just waiting to happen.
That's why we have a proper management API for platform devices. Please
use it, I didn't add the code for just for fun.
See platform_device_alloc() + platform_device_add_resources() +
platform_device_add_data() + platform_device_add() to create, and
platform_device_unregister() to destroy.
(Not looked at the rest because you really really need to get this
right first.)
next prev parent reply other threads:[~2007-11-22 0:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-20 20:40 [patch] 0/4 Support for Toshiba TMIO multifunction devices ian
2007-11-20 22:04 ` Dmitry Baryshkov
2007-11-20 22:20 ` ian
2007-11-21 2:23 ` eric miao
2007-11-21 3:54 ` ian
2007-11-21 4:05 ` eric miao
2007-11-22 0:34 ` [UPDATED PATCH] " ian
2007-11-22 0:52 ` Russell King - ARM Linux [this message]
2007-11-22 10:52 ` ian
2007-11-26 12:23 ` Russell King - ARM Linux
2007-11-22 0:49 ` [patch] 0/4 " Anton Vorontsov
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=20071122005230.GA6170@flint.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=dbaryshkov@gmail.com \
--cc=eric.y.miao@gmail.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=spyro@f2s.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox