mfd: Add devices platform data when the cell data size is not 0
authorBrian Harring <ferringb@gmail.com>
Mon, 18 Oct 2010 23:21:06 +0000 (01:21 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 28 Oct 2010 22:30:03 +0000 (00:30 +0200)
When the cell data_size is 0, the resulting platform_data pointer will be
set to ZERO_SIZE_PTR. That could be misleading for device drivers running
a NULL check on thei platform_data pointer before dereferencing it.

Signed-off-by: Brian Harring <ferringb@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/mfd-core.c

index d1c8605d4ed4825d12f2e7ad0c33196231f32c0b..ec99f681e77368b33bfa23718663c520508e0f6b 100644 (file)
@@ -38,10 +38,12 @@ static int mfd_add_device(struct device *parent, int id,
        pdev->dev.parent = parent;
        platform_set_drvdata(pdev, cell->driver_data);
 
-       ret = platform_device_add_data(pdev,
-                       cell->platform_data, cell->data_size);
-       if (ret)
-               goto fail_res;
+       if (cell->data_size) {
+               ret = platform_device_add_data(pdev,
+                                       cell->platform_data, cell->data_size);
+               if (ret)
+                       goto fail_res;
+       }
 
        for (r = 0; r < cell->num_resources; r++) {
                res[r].name = cell->resources[r].name;