Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e5e8de0 authored by Russell King's avatar Russell King Committed by Russell King
Browse files

[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: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 04ba0f65
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -131,7 +131,7 @@ static void cmx270_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
}
}




static struct pcmcia_low_level cmx270_pcmcia_ops = {
static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = {
	.owner			= THIS_MODULE,
	.owner			= THIS_MODULE,
	.hw_init		= cmx270_pcmcia_hw_init,
	.hw_init		= cmx270_pcmcia_hw_init,
	.hw_shutdown		= cmx270_pcmcia_shutdown,
	.hw_shutdown		= cmx270_pcmcia_shutdown,
@@ -156,10 +156,13 @@ static int __init cmx270_pcmcia_init(void)
	if (!cmx270_pcmcia_device)
	if (!cmx270_pcmcia_device)
		return -ENOMEM;
		return -ENOMEM;


	cmx270_pcmcia_device->dev.platform_data = &cmx270_pcmcia_ops;
	ret = platform_device_add_data(cmx270_pcmcia_device, &cmx270_pcmcia_ops,
				       sizeof(cmx270_pcmcia_ops));


	if (ret == 0) {
		printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n");
		printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n");
		ret = platform_device_add(cmx270_pcmcia_device);
		ret = platform_device_add(cmx270_pcmcia_device);
	}


	if (ret)
	if (ret)
		platform_device_put(cmx270_pcmcia_device);
		platform_device_put(cmx270_pcmcia_device);
+5 −4
Original line number Original line Diff line number Diff line
@@ -137,7 +137,7 @@ static void mst_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
{
{
}
}


static struct pcmcia_low_level mst_pcmcia_ops = {
static struct pcmcia_low_level mst_pcmcia_ops __initdata = {
	.owner			= THIS_MODULE,
	.owner			= THIS_MODULE,
	.hw_init		= mst_pcmcia_hw_init,
	.hw_init		= mst_pcmcia_hw_init,
	.hw_shutdown		= mst_pcmcia_hw_shutdown,
	.hw_shutdown		= mst_pcmcia_hw_shutdown,
@@ -161,8 +161,9 @@ static int __init mst_pcmcia_init(void)
	if (!mst_pcmcia_device)
	if (!mst_pcmcia_device)
		return -ENOMEM;
		return -ENOMEM;


	mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops;
	ret = platform_device_add_data(mst_pcmcia_device, &mst_pcmcia_ops,

				       sizeof(mst_pcmcia_ops));
	if (ret == 0)
		ret = platform_device_add(mst_pcmcia_device);
		ret = platform_device_add(mst_pcmcia_device);


	if (ret)
	if (ret)
+7 −5
Original line number Original line Diff line number Diff line
@@ -222,7 +222,7 @@ static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
	sharpsl_pcmcia_init_reset(skt);
	sharpsl_pcmcia_init_reset(skt);
}
}


static struct pcmcia_low_level sharpsl_pcmcia_ops = {
static struct pcmcia_low_level sharpsl_pcmcia_ops __initdata = {
	.owner                  = THIS_MODULE,
	.owner                  = THIS_MODULE,
	.hw_init                = sharpsl_pcmcia_hw_init,
	.hw_init                = sharpsl_pcmcia_hw_init,
	.hw_shutdown            = sharpsl_pcmcia_hw_shutdown,
	.hw_shutdown            = sharpsl_pcmcia_hw_shutdown,
@@ -261,10 +261,12 @@ static int __init sharpsl_pcmcia_init(void)
	if (!sharpsl_pcmcia_device)
	if (!sharpsl_pcmcia_device)
		return -ENOMEM;
		return -ENOMEM;


	sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
	ret = platform_device_add_data(sharpsl_pcmcia_device,
			&sharpsl_pcmcia_ops, sizeof(sharpsl_pcmcia_ops));
	if (ret == 0) {
		sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev;
		sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev;

		ret = platform_device_add(sharpsl_pcmcia_device);
		ret = platform_device_add(sharpsl_pcmcia_device);
	}


	if (ret)
	if (ret)
		platform_device_put(sharpsl_pcmcia_device);
		platform_device_put(sharpsl_pcmcia_device);