Thread (36 messages) flat view 36 messages, 5 authors, 2011-10-04

Re: [PATCH 2/9] regulator: helper routine to extract regulator_init_data

From: Russell King - ARM Linux <hidden>
Date: 2011-10-04 23:01:27
Also in: linux-arm-kernel, linux-omap

On Tue, Sep 27, 2011 at 01:10:04PM +0100, Mark Brown wrote:
On Tue, Sep 27, 2011 at 03:42:45PM +0530, Rajendra Nayak wrote:
quoted
+	init_data = devm_kzalloc(dev, sizeof(struct regulator_init_data),
+						 GFP_KERNEL);
+	if (!init_data)
+		return NULL; /* Out of memory? */
This means that the init data will be kept around for the entire
lifetime of the device rather than being discarded.
May I remind you that devm_* lifetime expires whenever the associated
driver is unbound, which can be much shorter than the lifetime of the
struct device.

It expires when any of the following occurs:
1. userspace asks the associated driver to be unbound
2. the driver is removed
3. any driver probe for this struct device fails
4. the struct device is unregistered.

So: don't use devm_* for anything other than stuff inside a driver being
associated with the struct device itself.  Other uses are a bug waiting
to happen.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help