aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/mfd-core.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 9c9c126ed334..6c0d1bec4b76 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -20,7 +20,7 @@ static int mfd_add_device(struct device *parent, int id,
20 struct resource *mem_base, 20 struct resource *mem_base,
21 int irq_base) 21 int irq_base)
22{ 22{
23 struct resource res[cell->num_resources]; 23 struct resource *res;
24 struct platform_device *pdev; 24 struct platform_device *pdev;
25 int ret = -ENOMEM; 25 int ret = -ENOMEM;
26 int r; 26 int r;
@@ -29,14 +29,17 @@ static int mfd_add_device(struct device *parent, int id,
29 if (!pdev) 29 if (!pdev)
30 goto fail_alloc; 30 goto fail_alloc;
31 31
32 res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL);
33 if (!res)
34 goto fail_device;
35
32 pdev->dev.parent = parent; 36 pdev->dev.parent = parent;
33 37
34 ret = platform_device_add_data(pdev, 38 ret = platform_device_add_data(pdev,
35 cell->platform_data, cell->data_size); 39 cell->platform_data, cell->data_size);
36 if (ret) 40 if (ret)
37 goto fail_device; 41 goto fail_res;
38 42
39 memset(res, 0, sizeof(res));
40 for (r = 0; r < cell->num_resources; r++) { 43 for (r = 0; r < cell->num_resources; r++) {
41 res[r].name = cell->resources[r].name; 44 res[r].name = cell->resources[r].name;
42 res[r].flags = cell->resources[r].flags; 45 res[r].flags = cell->resources[r].flags;
@@ -64,11 +67,15 @@ static int mfd_add_device(struct device *parent, int id,
64 67
65 ret = platform_device_add(pdev); 68 ret = platform_device_add(pdev);
66 if (ret) 69 if (ret)
67 goto fail_device; 70 goto fail_res;
71
72 kfree(res);
68 73
69 return 0; 74 return 0;
70 75
71/* platform_device_del(pdev); */ 76/* platform_device_del(pdev); */
77fail_res:
78 kfree(res);
72fail_device: 79fail_device:
73 platform_device_put(pdev); 80 platform_device_put(pdev);
74fail_alloc: 81fail_alloc: