diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-04-02 10:21:04 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-04-03 06:13:38 -0400 |
commit | 0a6d38795a405c49ea0012f04173613382def58c (patch) | |
tree | 41cca48cd41bdf3c9034b8f59ff5f4079f9bdaf2 /drivers | |
parent | 455c6fdbd219161bd09b1165f11699d6d73de11c (diff) |
spi: Always check complete callback before calling it
Since commit 1e25cd4729bd "spi: Do not require a completion", this checking is
required to prevent NULL pointer dereference.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/spi/spi-fsl-espi.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-fsl-spi.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-mpc512x-psc.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-mpc52xx-psc.c | 3 | ||||
-rw-r--r-- | drivers/spi/spi-mpc52xx.c | 6 | ||||
-rw-r--r-- | drivers/spi/spi-sh.c | 6 | ||||
-rw-r--r-- | drivers/spi/spi-txx9.c | 3 |
7 files changed, 18 insertions, 9 deletions
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 428dc7a6b62e..e8e3d34bab07 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c | |||
@@ -446,7 +446,8 @@ static void fsl_espi_do_one_msg(struct spi_message *m) | |||
446 | 446 | ||
447 | m->actual_length = espi_trans.actual_length; | 447 | m->actual_length = espi_trans.actual_length; |
448 | m->status = espi_trans.status; | 448 | m->status = espi_trans.status; |
449 | m->complete(m->context); | 449 | if (m->complete) |
450 | m->complete(m->context); | ||
450 | } | 451 | } |
451 | 452 | ||
452 | static int fsl_espi_setup(struct spi_device *spi) | 453 | static int fsl_espi_setup(struct spi_device *spi) |
diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 119f7af94537..f2af3eb3ceb7 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c | |||
@@ -404,7 +404,8 @@ static void fsl_spi_do_one_msg(struct spi_message *m) | |||
404 | } | 404 | } |
405 | 405 | ||
406 | m->status = status; | 406 | m->status = status; |
407 | m->complete(m->context); | 407 | if (m->complete) |
408 | m->complete(m->context); | ||
408 | 409 | ||
409 | if (status || !cs_change) { | 410 | if (status || !cs_change) { |
410 | ndelay(nsecs); | 411 | ndelay(nsecs); |
diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 5032141eeeec..8eee745e8471 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c | |||
@@ -301,7 +301,8 @@ static int mpc512x_psc_spi_msg_xfer(struct spi_master *master, | |||
301 | } | 301 | } |
302 | 302 | ||
303 | m->status = status; | 303 | m->status = status; |
304 | m->complete(m->context); | 304 | if (m->complete) |
305 | m->complete(m->context); | ||
305 | 306 | ||
306 | if (status || !cs_change) | 307 | if (status || !cs_change) |
307 | mpc512x_psc_spi_deactivate_cs(spi); | 308 | mpc512x_psc_spi_deactivate_cs(spi); |
diff --git a/drivers/spi/spi-mpc52xx-psc.c b/drivers/spi/spi-mpc52xx-psc.c index 00ba910ab302..d761bc0dc5ce 100644 --- a/drivers/spi/spi-mpc52xx-psc.c +++ b/drivers/spi/spi-mpc52xx-psc.c | |||
@@ -248,7 +248,8 @@ static void mpc52xx_psc_spi_work(struct work_struct *work) | |||
248 | } | 248 | } |
249 | 249 | ||
250 | m->status = status; | 250 | m->status = status; |
251 | m->complete(m->context); | 251 | if (m->complete) |
252 | m->complete(m->context); | ||
252 | 253 | ||
253 | if (status || !cs_change) | 254 | if (status || !cs_change) |
254 | mpc52xx_psc_spi_deactivate_cs(spi); | 255 | mpc52xx_psc_spi_deactivate_cs(spi); |
diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c index 7c675fe83101..a0de12ac1deb 100644 --- a/drivers/spi/spi-mpc52xx.c +++ b/drivers/spi/spi-mpc52xx.c | |||
@@ -235,7 +235,8 @@ static int mpc52xx_spi_fsmstate_transfer(int irq, struct mpc52xx_spi *ms, | |||
235 | dev_err(&ms->master->dev, "mode fault\n"); | 235 | dev_err(&ms->master->dev, "mode fault\n"); |
236 | mpc52xx_spi_chipsel(ms, 0); | 236 | mpc52xx_spi_chipsel(ms, 0); |
237 | ms->message->status = -EIO; | 237 | ms->message->status = -EIO; |
238 | ms->message->complete(ms->message->context); | 238 | if (ms->message->complete) |
239 | ms->message->complete(ms->message->context); | ||
239 | ms->state = mpc52xx_spi_fsmstate_idle; | 240 | ms->state = mpc52xx_spi_fsmstate_idle; |
240 | return FSM_CONTINUE; | 241 | return FSM_CONTINUE; |
241 | } | 242 | } |
@@ -289,7 +290,8 @@ mpc52xx_spi_fsmstate_wait(int irq, struct mpc52xx_spi *ms, u8 status, u8 data) | |||
289 | ms->msg_count++; | 290 | ms->msg_count++; |
290 | mpc52xx_spi_chipsel(ms, 0); | 291 | mpc52xx_spi_chipsel(ms, 0); |
291 | ms->message->status = 0; | 292 | ms->message->status = 0; |
292 | ms->message->complete(ms->message->context); | 293 | if (ms->message->complete) |
294 | ms->message->complete(ms->message->context); | ||
293 | ms->state = mpc52xx_spi_fsmstate_idle; | 295 | ms->state = mpc52xx_spi_fsmstate_idle; |
294 | return FSM_CONTINUE; | 296 | return FSM_CONTINUE; |
295 | } | 297 | } |
diff --git a/drivers/spi/spi-sh.c b/drivers/spi/spi-sh.c index f6f2c7010177..03edf5ed0e9f 100644 --- a/drivers/spi/spi-sh.c +++ b/drivers/spi/spi-sh.c | |||
@@ -322,7 +322,8 @@ static void spi_sh_work(struct work_struct *work) | |||
322 | spin_lock_irqsave(&ss->lock, flags); | 322 | spin_lock_irqsave(&ss->lock, flags); |
323 | 323 | ||
324 | mesg->status = 0; | 324 | mesg->status = 0; |
325 | mesg->complete(mesg->context); | 325 | if (mesg->complete) |
326 | mesg->complete(mesg->context); | ||
326 | } | 327 | } |
327 | 328 | ||
328 | clear_fifo(ss); | 329 | clear_fifo(ss); |
@@ -340,7 +341,8 @@ static void spi_sh_work(struct work_struct *work) | |||
340 | 341 | ||
341 | error: | 342 | error: |
342 | mesg->status = ret; | 343 | mesg->status = ret; |
343 | mesg->complete(mesg->context); | 344 | if (mesg->complete) |
345 | mesg->complete(mesg->context); | ||
344 | 346 | ||
345 | spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD, | 347 | spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD, |
346 | SPI_SH_CR1); | 348 | SPI_SH_CR1); |
diff --git a/drivers/spi/spi-txx9.c b/drivers/spi/spi-txx9.c index 6191ced514b2..57a14977101c 100644 --- a/drivers/spi/spi-txx9.c +++ b/drivers/spi/spi-txx9.c | |||
@@ -265,7 +265,8 @@ static void txx9spi_work_one(struct txx9spi *c, struct spi_message *m) | |||
265 | 265 | ||
266 | exit: | 266 | exit: |
267 | m->status = status; | 267 | m->status = status; |
268 | m->complete(m->context); | 268 | if (m->complete) |
269 | m->complete(m->context); | ||
269 | 270 | ||
270 | /* normally deactivate chipselect ... unless no error and | 271 | /* normally deactivate chipselect ... unless no error and |
271 | * cs_change has hinted that the next message will probably | 272 | * cs_change has hinted that the next message will probably |