* [PATCH] spi: fix NULL pointer dereferences by checking dmaengine_prep_slave_sg
@ 2019-03-14 6:42 Kangjie Lu
2019-03-14 8:17 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-14 6:42 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Kukjin Kim, Krzysztof Kozlowski, Andi Shyti,
Mark Brown, linux-arm-kernel, linux-samsung-soc, linux-spi,
linux-kernel
In case dmaengine_prep_slave_sg fails, the fix returns to avoid
NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/spi/spi-s3c64xx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 7b7151ec14c8..3a5f161ce558 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -293,6 +293,8 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
desc = dmaengine_prep_slave_sg(dma->ch, sgt->sgl, sgt->nents,
dma->direction, DMA_PREP_INTERRUPT);
+ if (!desc)
+ return;
desc->callback = s3c64xx_spi_dmacb;
desc->callback_param = dma;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] spi: fix NULL pointer dereferences by checking dmaengine_prep_slave_sg
2019-03-14 6:42 [PATCH] spi: fix NULL pointer dereferences by checking dmaengine_prep_slave_sg Kangjie Lu
@ 2019-03-14 8:17 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2019-03-14 8:17 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Kukjin Kim, Andi Shyti, Mark Brown, linux-arm-kernel,
linux-samsung-soc, linux-spi, linux-kernel
On Thu, 14 Mar 2019 at 07:42, Kangjie Lu <kjlu@umn.edu> wrote:
>
> In case dmaengine_prep_slave_sg fails, the fix returns to avoid
> NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Hi,
Thanks for the patch, but the fix is the same as here:
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1402451.html
and the answer is the same as there - I think you did not handle the
error at all. Did you test the error path in this case? How does it
behave? I think there is no point to replace one NULL pointer to
another NULL pointer right after it. :)
Best regards,
Krzysztof
> ---
> drivers/spi/spi-s3c64xx.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
> index 7b7151ec14c8..3a5f161ce558 100644
> --- a/drivers/spi/spi-s3c64xx.c
> +++ b/drivers/spi/spi-s3c64xx.c
> @@ -293,6 +293,8 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
>
> desc = dmaengine_prep_slave_sg(dma->ch, sgt->sgl, sgt->nents,
> dma->direction, DMA_PREP_INTERRUPT);
> + if (!desc)
> + return;
>
> desc->callback = s3c64xx_spi_dmacb;
> desc->callback_param = dma;
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-14 8:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 6:42 [PATCH] spi: fix NULL pointer dereferences by checking dmaengine_prep_slave_sg Kangjie Lu
2019-03-14 8:17 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).