summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-sh-sci.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2014-03-13 10:32:37 +0800
committerMark Brown <broonie@linaro.org>2014-03-13 13:40:51 +0000
commited8eb250d7b097dbd888e46ad0d35a2cb1858221 (patch)
treef955d8f10d2daa01f0bd5fed49cdd6f74dbb40eb /drivers/spi/spi-sh-sci.c
parent38dbfb59d1175ef458d006556061adeaa8751b72 (diff)
downloadlinux-ed8eb250d7b097dbd888e46ad0d35a2cb1858221.tar.bz2
spi: sh-sci: Prevent NULL pointer dereference
If sp->info is NULL, we will hit NULL pointer dereference in probe() while setting bus_num and num_chipselect for master: sp->bitbang.master->bus_num = sp->info->bus_num; sp->bitbang.master->num_chipselect = sp->info->num_chipselect; Thus add NULL test for sp->info in probe() to prevent NULL pointer dereference. Signed-off-by: Axel Lin <axel.lin@ingics.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-sh-sci.c')
-rw-r--r--drivers/spi/spi-sh-sci.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/spi/spi-sh-sci.c b/drivers/spi/spi-sh-sci.c
index 38eb24df796c..41b1346b29d5 100644
--- a/drivers/spi/spi-sh-sci.c
+++ b/drivers/spi/spi-sh-sci.c
@@ -109,7 +109,7 @@ static void sh_sci_spi_chipselect(struct spi_device *dev, int value)
{
struct sh_sci_spi *sp = spi_master_get_devdata(dev->master);
- if (sp->info && sp->info->chip_select)
+ if (sp->info->chip_select)
(sp->info->chip_select)(sp->info, dev->chip_select, value);
}
@@ -131,6 +131,11 @@ static int sh_sci_spi_probe(struct platform_device *dev)
platform_set_drvdata(dev, sp);
sp->info = dev_get_platdata(&dev->dev);
+ if (!sp->info) {
+ dev_err(&dev->dev, "platform data is missing\n");
+ ret = -ENOENT;
+ goto err1;
+ }
/* setup spi bitbang adaptor */
sp->bitbang.master = master;