aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/pxa2xx_cm_x270.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-04-24 10:28:11 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-06-02 08:49:16 -0400
commit4e5e8de0dbdeb08df2b4c15fa2b0ba2216091793 (patch)
treecda179e4e8e7eaf1984f90638fba143b6dd8b228 /drivers/pcmcia/pxa2xx_cm_x270.c
parent04ba0f656f7580d8a51a5b3441e088309141b67a (diff)
[ARM] pxa: avoid kfreeing static data if platform device fails to register
When a dynamically allocated platform device is 'put', the platform device's platform_data is kfree'd. This is bad if it's pointing at static data. Use the provided function to register platform data for these devices. This also means we can mark the pcmcia ops structures as __initdata. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/pcmcia/pxa2xx_cm_x270.c')
-rw-r--r--drivers/pcmcia/pxa2xx_cm_x270.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/pcmcia/pxa2xx_cm_x270.c b/drivers/pcmcia/pxa2xx_cm_x270.c
index 4a6c020afb37..f123fce65f2e 100644
--- a/drivers/pcmcia/pxa2xx_cm_x270.c
+++ b/drivers/pcmcia/pxa2xx_cm_x270.c
@@ -131,7 +131,7 @@ static void cmx270_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
131} 131}
132 132
133 133
134static struct pcmcia_low_level cmx270_pcmcia_ops = { 134static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = {
135 .owner = THIS_MODULE, 135 .owner = THIS_MODULE,
136 .hw_init = cmx270_pcmcia_hw_init, 136 .hw_init = cmx270_pcmcia_hw_init,
137 .hw_shutdown = cmx270_pcmcia_shutdown, 137 .hw_shutdown = cmx270_pcmcia_shutdown,
@@ -156,10 +156,13 @@ static int __init cmx270_pcmcia_init(void)
156 if (!cmx270_pcmcia_device) 156 if (!cmx270_pcmcia_device)
157 return -ENOMEM; 157 return -ENOMEM;
158 158
159 cmx270_pcmcia_device->dev.platform_data = &cmx270_pcmcia_ops; 159 ret = platform_device_add_data(cmx270_pcmcia_device, &cmx270_pcmcia_ops,
160 sizeof(cmx270_pcmcia_ops));
160 161
161 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n"); 162 if (ret == 0) {
162 ret = platform_device_add(cmx270_pcmcia_device); 163 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n");
164 ret = platform_device_add(cmx270_pcmcia_device);
165 }
163 166
164 if (ret) 167 if (ret)
165 platform_device_put(cmx270_pcmcia_device); 168 platform_device_put(cmx270_pcmcia_device);