mfd: Add missing out of memory check for pcf50633
authorAlan Cox <alan@lxorguk.ukuu.org.uk>
Fri, 13 Jul 2012 15:43:32 +0000 (16:43 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 16 Jul 2012 13:55:41 +0000 (15:55 +0200)
Resolves-bug: https://bugzilla.kernel.org/show_bug.cgi?id=44561
Reported-by: <rucsoftsec@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/pcf50633-core.c

index 29c122bf28ea723e36cafccda86eb09319d595ac..45ce1fb5a54998dee46e4f523c3428e172cba2a4 100644 (file)
@@ -253,8 +253,13 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
                }
 
                pdev->dev.parent = pcf->dev;
-               platform_device_add_data(pdev, &pdata->reg_init_data[i],
-                                       sizeof(pdata->reg_init_data[i]));
+               if (platform_device_add_data(pdev, &pdata->reg_init_data[i],
+                                       sizeof(pdata->reg_init_data[i])) < 0) {
+                       platform_device_put(pdev);
+                       dev_err(pcf->dev, "Out of memory for regulator parameters %d\n",
+                                                                       i);
+                       continue;
+               }
                pcf->regulator_pdev[i] = pdev;
 
                platform_device_add(pdev);