LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved
@ 2017-11-20 14:28 Gustavo A. R. Silva
2017-11-23 10:11 ` Ludovic Desroches
2017-11-29 14:19 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-11-20 14:28 UTC (permalink / raw)
To: Ludovic Desroches, Vinod Koul, Dan Williams
Cc: linux-arm-kernel, dmaengine, linux-kernel, Gustavo A. R. Silva
_xt_ is being dereferenced before it is null checked, hence there is a
potential null pointer dereference.
Fix this by moving the pointer dereference after _xt_ has been null
checked.
This issue was detected with the help of Coccinelle.
Fixes: 4483320e241c ("dmaengine: Use Pointer xt after NULL check.")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
drivers/dma/at_hdmac.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index fbab271..a861b5b 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -708,7 +708,7 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
unsigned long flags)
{
struct at_dma_chan *atchan = to_at_dma_chan(chan);
- struct data_chunk *first = xt->sgl;
+ struct data_chunk *first;
struct at_desc *desc = NULL;
size_t xfer_count;
unsigned int dwidth;
@@ -720,6 +720,8 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
if (unlikely(!xt || xt->numf != 1 || !xt->frame_size))
return NULL;
+ first = xt->sgl;
+
dev_info(chan2dev(chan),
"%s: src=%pad, dest=%pad, numf=%d, frame_size=%d, flags=0x%lx\n",
__func__, &xt->src_start, &xt->dst_start, xt->numf,
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved
2017-11-20 14:28 [PATCH] dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved Gustavo A. R. Silva
@ 2017-11-23 10:11 ` Ludovic Desroches
2017-11-29 14:19 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Desroches @ 2017-11-23 10:11 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Ludovic Desroches, Vinod Koul, Dan Williams, dmaengine,
linux-kernel, linux-arm-kernel
On Mon, Nov 20, 2017 at 08:28:14AM -0600, Gustavo A. R. Silva wrote:
> _xt_ is being dereferenced before it is null checked, hence there is a
> potential null pointer dereference.
>
> Fix this by moving the pointer dereference after _xt_ has been null
> checked.
>
> This issue was detected with the help of Coccinelle.
>
> Fixes: 4483320e241c ("dmaengine: Use Pointer xt after NULL check.")
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Thanks
> ---
> drivers/dma/at_hdmac.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
> index fbab271..a861b5b 100644
> --- a/drivers/dma/at_hdmac.c
> +++ b/drivers/dma/at_hdmac.c
> @@ -708,7 +708,7 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
> unsigned long flags)
> {
> struct at_dma_chan *atchan = to_at_dma_chan(chan);
> - struct data_chunk *first = xt->sgl;
> + struct data_chunk *first;
> struct at_desc *desc = NULL;
> size_t xfer_count;
> unsigned int dwidth;
> @@ -720,6 +720,8 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
> if (unlikely(!xt || xt->numf != 1 || !xt->frame_size))
> return NULL;
>
> + first = xt->sgl;
> +
> dev_info(chan2dev(chan),
> "%s: src=%pad, dest=%pad, numf=%d, frame_size=%d, flags=0x%lx\n",
> __func__, &xt->src_start, &xt->dst_start, xt->numf,
> --
> 2.7.4
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved
2017-11-20 14:28 [PATCH] dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved Gustavo A. R. Silva
2017-11-23 10:11 ` Ludovic Desroches
@ 2017-11-29 14:19 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2017-11-29 14:19 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Ludovic Desroches, Dan Williams, linux-arm-kernel, dmaengine,
linux-kernel
On Mon, Nov 20, 2017 at 08:28:14AM -0600, Gustavo A. R. Silva wrote:
> _xt_ is being dereferenced before it is null checked, hence there is a
> potential null pointer dereference.
>
> Fix this by moving the pointer dereference after _xt_ has been null
> checked.
>
> This issue was detected with the help of Coccinelle.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-29 14:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-20 14:28 [PATCH] dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved Gustavo A. R. Silva
2017-11-23 10:11 ` Ludovic Desroches
2017-11-29 14:19 ` Vinod Koul
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).