Commit a28dbea0ad3bd8144f3348eb5c20fabc2f12b4b5

Authored by Brian Harring
Committed by Samuel Ortiz
1 parent 11c39c4bde

mfd: Add devices platform data when the cell data size is not 0

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>

Showing 1 changed file with 6 additions and 4 deletions Side-by-side Diff

drivers/mfd/mfd-core.c
... ... @@ -38,10 +38,12 @@
38 38 pdev->dev.parent = parent;
39 39 platform_set_drvdata(pdev, cell->driver_data);
40 40  
41   - ret = platform_device_add_data(pdev,
42   - cell->platform_data, cell->data_size);
43   - if (ret)
44   - goto fail_res;
  41 + if (cell->data_size) {
  42 + ret = platform_device_add_data(pdev,
  43 + cell->platform_data, cell->data_size);
  44 + if (ret)
  45 + goto fail_res;
  46 + }
45 47  
46 48 for (r = 0; r < cell->num_resources; r++) {
47 49 res[r].name = cell->resources[r].name;