Skip to content

Commit

Permalink
mfd: Add devices platform data when the cell data size is not 0
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Samuel Ortiz <[email protected]>
  • Loading branch information
ferringb authored and Samuel Ortiz committed Oct 28, 2010
1 parent 11c39c4 commit a28dbea
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/mfd/mfd-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a28dbea

Please sign in to comment.