Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1647510 > unrolled thread
| Started by | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| First post | 2017-05-23 02:30 +0200 |
| Last post | 2017-05-23 09:40 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] spi: add null check before pointer dereference "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-05-23 02:30 +0200
Re: [PATCH] spi: add null check before pointer dereference Krzysztof Kozlowski <krzk@kernel.org> - 2017-05-23 09:30 +0200
Re: [PATCH] spi: add null check before pointer dereference Geert Uytterhoeven <geert@linux-m68k.org> - 2017-05-23 09:40 +0200
| From | "Gustavo A. R. Silva" <garsilva@embeddedor.com> |
|---|---|
| Date | 2017-05-23 02:30 +0200 |
| Subject | [PATCH] spi: add null check before pointer dereference |
| Message-ID | <tK5S1-4cN-1@gated-at.bofh.it> |
Add null check before dereferencing pointer desc
Addresses-Coverity-ID: 1397997
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
drivers/spi/spi-s3c64xx.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index b392cca..9f1013e 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -306,6 +306,12 @@ 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) {
+ dev_err(&sdd->master->dev,
+ "%s:dmaengine_prep_slave_sg Failed\n", __func__);
+ return;
+ }
+
desc->callback = s3c64xx_spi_dmacb;
desc->callback_param = dma;
--
2.5.0
[toc] | [next] | [standalone]
| From | Krzysztof Kozlowski <krzk@kernel.org> |
|---|---|
| Date | 2017-05-23 09:30 +0200 |
| Message-ID | <tKcqv-8q9-27@gated-at.bofh.it> |
| In reply to | #1647510 |
On Tue, May 23, 2017 at 2:25 AM, Gustavo A. R. Silva
<garsilva@embeddedor.com> wrote:
> Add null check before dereferencing pointer desc
>
> Addresses-Coverity-ID: 1397997
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> drivers/spi/spi-s3c64xx.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
> index b392cca..9f1013e 100644
> --- a/drivers/spi/spi-s3c64xx.c
> +++ b/drivers/spi/spi-s3c64xx.c
> @@ -306,6 +306,12 @@ 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) {
> + dev_err(&sdd->master->dev,
> + "%s:dmaengine_prep_slave_sg Failed\n", __func__);
> + return;
> + }
Although the check itself looks needed, but I think you did not handle
the error at all. You just bail out before submitting dma descriptor
but except that, everything else goes like there was no error. It
might work, might not... did you test this error path? How does it
behave?
Best regards,
Krzysztof
[toc] | [prev] | [next] | [standalone]
| From | Geert Uytterhoeven <geert@linux-m68k.org> |
|---|---|
| Date | 2017-05-23 09:40 +0200 |
| Message-ID | <tKcA9-8tW-13@gated-at.bofh.it> |
| In reply to | #1647726 |
On Tue, May 23, 2017 at 9:24 AM, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> On Tue, May 23, 2017 at 2:25 AM, Gustavo A. R. Silva
> <garsilva@embeddedor.com> wrote:
>> Add null check before dereferencing pointer desc
>>
>> Addresses-Coverity-ID: 1397997
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>> ---
>> drivers/spi/spi-s3c64xx.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
>> index b392cca..9f1013e 100644
>> --- a/drivers/spi/spi-s3c64xx.c
>> +++ b/drivers/spi/spi-s3c64xx.c
>> @@ -306,6 +306,12 @@ 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) {
>> + dev_err(&sdd->master->dev,
>> + "%s:dmaengine_prep_slave_sg Failed\n", __func__);
>> + return;
>> + }
>
> Although the check itself looks needed, but I think you did not handle
> the error at all. You just bail out before submitting dma descriptor
> but except that, everything else goes like there was no error. It
> might work, might not... did you test this error path? How does it
> behave?
I.e. does it fall back to PIO?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web