aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-mpc52xx.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2014-04-02 10:21:04 -0400
committerMark Brown <broonie@linaro.org>2014-04-03 06:13:38 -0400
commit0a6d38795a405c49ea0012f04173613382def58c (patch)
tree41cca48cd41bdf3c9034b8f59ff5f4079f9bdaf2 /drivers/spi/spi-mpc52xx.c
parent455c6fdbd219161bd09b1165f11699d6d73de11c (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/spi/spi-mpc52xx.c')
-rw-r--r--drivers/spi/spi-mpc52xx.c6
1 files changed, 4 insertions, 2 deletions
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 }