Skip to content

Commit

Permalink
spi: orion: fix potential NULL pointer de-reference
Browse files Browse the repository at this point in the history
It's possible that the call to of_match_device() (introduced in commit
df59fa7 ["spi: orion: support armada extended baud rates"]) may return
a NULL if there is no match in the device tree (or perhaps no device tree
at all). Check the return pointer and set the local device data to the
lowest common denominator orion device data if it is NULL.

Reported-by: Karl Beldan <karl.beldan@gmail.com>
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Greg Ungerer authored and Mark Brown committed Oct 22, 2014
1 parent f114040 commit 9a2d363
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/spi/spi-orion.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ static int orion_spi_probe(struct platform_device *pdev)
spi->master = master;

of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
devdata = of_id->data;
devdata = (of_id) ? of_id->data : &orion_spi_dev_data;
spi->devdata = devdata;

spi->clk = devm_clk_get(&pdev->dev, NULL);
Expand Down

0 comments on commit 9a2d363

Please sign in to comment.