提交 0a6d3879 编写于 作者: A Axel Lin 提交者: Mark Brown

spi: Always check complete callback before calling it

Since commit 1e25cd47 "spi: Do not require a completion", this checking is
required to prevent NULL pointer dereference.
Signed-off-by: NAxel Lin <axel.lin@ingics.com>
Signed-off-by: NMark Brown <broonie@linaro.org>
上级 455c6fdb
......@@ -446,6 +446,7 @@ static void fsl_espi_do_one_msg(struct spi_message *m)
m->actual_length = espi_trans.actual_length;
m->status = espi_trans.status;
if (m->complete)
m->complete(m->context);
}
......
......@@ -404,6 +404,7 @@ static void fsl_spi_do_one_msg(struct spi_message *m)
}
m->status = status;
if (m->complete)
m->complete(m->context);
if (status || !cs_change) {
......
......@@ -301,6 +301,7 @@ static int mpc512x_psc_spi_msg_xfer(struct spi_master *master,
}
m->status = status;
if (m->complete)
m->complete(m->context);
if (status || !cs_change)
......
......@@ -248,6 +248,7 @@ static void mpc52xx_psc_spi_work(struct work_struct *work)
}
m->status = status;
if (m->complete)
m->complete(m->context);
if (status || !cs_change)
......
......@@ -235,6 +235,7 @@ static int mpc52xx_spi_fsmstate_transfer(int irq, struct mpc52xx_spi *ms,
dev_err(&ms->master->dev, "mode fault\n");
mpc52xx_spi_chipsel(ms, 0);
ms->message->status = -EIO;
if (ms->message->complete)
ms->message->complete(ms->message->context);
ms->state = mpc52xx_spi_fsmstate_idle;
return FSM_CONTINUE;
......@@ -289,6 +290,7 @@ mpc52xx_spi_fsmstate_wait(int irq, struct mpc52xx_spi *ms, u8 status, u8 data)
ms->msg_count++;
mpc52xx_spi_chipsel(ms, 0);
ms->message->status = 0;
if (ms->message->complete)
ms->message->complete(ms->message->context);
ms->state = mpc52xx_spi_fsmstate_idle;
return FSM_CONTINUE;
......
......@@ -322,6 +322,7 @@ static void spi_sh_work(struct work_struct *work)
spin_lock_irqsave(&ss->lock, flags);
mesg->status = 0;
if (mesg->complete)
mesg->complete(mesg->context);
}
......@@ -340,6 +341,7 @@ static void spi_sh_work(struct work_struct *work)
error:
mesg->status = ret;
if (mesg->complete)
mesg->complete(mesg->context);
spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD,
......
......@@ -265,6 +265,7 @@ static void txx9spi_work_one(struct txx9spi *c, struct spi_message *m)
exit:
m->status = status;
if (m->complete)
m->complete(m->context);
/* normally deactivate chipselect ... unless no error and
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册