All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: add null check before pointer dereference
@ 2017-05-23  0:25   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 12+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-23  0:25 UTC (permalink / raw)
  To: Kukjin Kim, Krzysztof Kozlowski, Andi Shyti, Mark Brown
  Cc: linux-arm-kernel, linux-samsung-soc, linux-spi, linux-kernel,
	Gustavo A. R. Silva

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] spi: add null check before pointer dereference
@ 2017-05-23  0:25   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 12+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-23  0:25 UTC (permalink / raw)
  To: linux-arm-kernel

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] spi: add null check before pointer dereference
  2017-05-23  0:25   ` Gustavo A. R. Silva
@ 2017-05-23  7:24     ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2017-05-23  7:24 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Kukjin Kim, Andi Shyti, Mark Brown, linux-arm-kernel,
	linux-samsung-soc, linux-spi, linux-kernel

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] spi: add null check before pointer dereference
@ 2017-05-23  7:24     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kozlowski @ 2017-05-23  7:24 UTC (permalink / raw)
  To: linux-arm-kernel

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] spi: add null check before pointer dereference
@ 2017-05-23  7:33       ` Geert Uytterhoeven
  0 siblings, 0 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2017-05-23  7:33 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Gustavo A. R. Silva, Kukjin Kim, Andi Shyti, Mark Brown,
	linux-arm-kernel, linux-samsung-soc, linux-spi, linux-kernel

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] spi: add null check before pointer dereference
@ 2017-05-23  7:33       ` Geert Uytterhoeven
  0 siblings, 0 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2017-05-23  7:33 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Gustavo A. R. Silva, Kukjin Kim, Andi Shyti, Mark Brown,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, linux-spi,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Tue, May 23, 2017 at 9:24 AM, Krzysztof Kozlowski <krzk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> On Tue, May 23, 2017 at 2:25 AM, Gustavo A. R. Silva
> <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org> wrote:
>> Add null check before dereferencing pointer desc
>>
>> Addresses-Coverity-ID: 1397997
>> Signed-off-by: Gustavo A. R. Silva <garsilva-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>
>> ---
>>  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-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.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
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] spi: add null check before pointer dereference
@ 2017-05-23  7:33       ` Geert Uytterhoeven
  0 siblings, 0 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2017-05-23  7:33 UTC (permalink / raw)
  To: linux-arm-kernel

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 at 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] spi: add null check before pointer dereference
  2017-05-23  0:25   ` Gustavo A. R. Silva
@ 2017-05-29  3:59     ` Andi Shyti
  -1 siblings, 0 replies; 12+ messages in thread
From: Andi Shyti @ 2017-05-29  3:59 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Kukjin Kim, Krzysztof Kozlowski, Mark Brown, linux-arm-kernel,
	linux-samsung-soc, linux-spi, linux-kernel

Hi Gustavo,

>  	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;
> +	}
> +

I'm sorry, I would nack this patch for now. There was a smilar I
sent before, but, as Krzysztof said, this needs more testing and
a proper solution.

That's anyway in my todo list.

Thanks,
Andi

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] spi: add null check before pointer dereference
@ 2017-05-29  3:59     ` Andi Shyti
  0 siblings, 0 replies; 12+ messages in thread
From: Andi Shyti @ 2017-05-29  3:59 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Gustavo,

>  	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;
> +	}
> +

I'm sorry, I would nack this patch for now. There was a smilar I
sent before, but, as Krzysztof said, this needs more testing and
a proper solution.

That's anyway in my todo list.

Thanks,
Andi

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] spi: add null check before pointer dereference
  2017-05-29  3:59     ` Andi Shyti
  (?)
@ 2017-05-30  2:33       ` Gustavo A. R. Silva
  -1 siblings, 0 replies; 12+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-30  2:33 UTC (permalink / raw)
  To: Andi Shyti
  Cc: Kukjin Kim, Krzysztof Kozlowski, Mark Brown, linux-arm-kernel,
	linux-samsung-soc, linux-spi, linux-kernel

Hi Andi,

Quoting Andi Shyti <andi.shyti@samsung.com>:

> Hi Gustavo,
>
>>  	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;
>> +	}
>> +
>
> I'm sorry, I would nack this patch for now. There was a smilar I
> sent before, but, as Krzysztof said, this needs more testing and
> a proper solution.
>

Yeah, I get it.

> That's anyway in my todo list.
>

That's great.

> Thanks,
> Andi

Thanks!
--
Gustavo A. R. Silva

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] spi: add null check before pointer dereference
@ 2017-05-30  2:33       ` Gustavo A. R. Silva
  0 siblings, 0 replies; 12+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-30  2:33 UTC (permalink / raw)
  To: Andi Shyti
  Cc: linux-samsung-soc, linux-kernel, Krzysztof Kozlowski, linux-spi,
	Mark Brown, Kukjin Kim, linux-arm-kernel

Hi Andi,

Quoting Andi Shyti <andi.shyti@samsung.com>:

> Hi Gustavo,
>
>>  	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;
>> +	}
>> +
>
> I'm sorry, I would nack this patch for now. There was a smilar I
> sent before, but, as Krzysztof said, this needs more testing and
> a proper solution.
>

Yeah, I get it.

> That's anyway in my todo list.
>

That's great.

> Thanks,
> Andi

Thanks!
--
Gustavo A. R. Silva

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] spi: add null check before pointer dereference
@ 2017-05-30  2:33       ` Gustavo A. R. Silva
  0 siblings, 0 replies; 12+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-30  2:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Andi,

Quoting Andi Shyti <andi.shyti@samsung.com>:

> Hi Gustavo,
>
>>  	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;
>> +	}
>> +
>
> I'm sorry, I would nack this patch for now. There was a smilar I
> sent before, but, as Krzysztof said, this needs more testing and
> a proper solution.
>

Yeah, I get it.

> That's anyway in my todo list.
>

That's great.

> Thanks,
> Andi

Thanks!
--
Gustavo A. R. Silva

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-05-30  2:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170523002511epcas4p3b7737552432363b089e4a9018e43f6f5@epcas4p3.samsung.com>
2017-05-23  0:25 ` [PATCH] spi: add null check before pointer dereference Gustavo A. R. Silva
2017-05-23  0:25   ` Gustavo A. R. Silva
2017-05-23  7:24   ` Krzysztof Kozlowski
2017-05-23  7:24     ` Krzysztof Kozlowski
2017-05-23  7:33     ` Geert Uytterhoeven
2017-05-23  7:33       ` Geert Uytterhoeven
2017-05-23  7:33       ` Geert Uytterhoeven
2017-05-29  3:59   ` Andi Shyti
2017-05-29  3:59     ` Andi Shyti
2017-05-30  2:33     ` Gustavo A. R. Silva
2017-05-30  2:33       ` Gustavo A. R. Silva
2017-05-30  2:33       ` Gustavo A. R. Silva

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.