All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] NTB: ntb_perf: Fix address err in perf_copy_chunk
@ 2020-04-06 10:41 Dan Carpenter
  2020-04-08  4:33 ` Jiasen Lin
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-04-06 10:41 UTC (permalink / raw)
  To: linjiasen; +Cc: linux-ntb

Hello Jiasen Lin,

This is a semi-automatic email about new static checker warnings.

The patch 99a06056124d: "NTB: ntb_perf: Fix address err in
perf_copy_chunk" from Nov 20, 2019, leads to the following Smatch
complaint:

    drivers/ntb/test/ntb_perf.c:1017 perf_clear_test()
    warn: variable dereferenced before check 'pthr->dma_chan' (see line 1011)

drivers/ntb/test/ntb_perf.c
  1010		 */
  1011		(void)dmaengine_terminate_sync(pthr->dma_chan);
                                               ^^^^^^^^^^^^^^
"pthr->dma_chan" is dereferenced inside the function.

  1012		if (pthr->perf->test_peer->dma_dst_addr)
  1013			dma_unmap_resource(pthr->dma_chan->device->dev,
  1014					   pthr->perf->test_peer->dma_dst_addr,
  1015					   pthr->perf->test_peer->outbuf_size,
  1016					   DMA_FROM_DEVICE, 0);
  1017		if (pthr->dma_chan)
                    ^^^^^^^^^^^^^^
This new NULL check is too late.

  1018			dma_release_channel(pthr->dma_chan);
  1019	

regards,
dan carpenter

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

* Re: [bug report] NTB: ntb_perf: Fix address err in perf_copy_chunk
  2020-04-06 10:41 [bug report] NTB: ntb_perf: Fix address err in perf_copy_chunk Dan Carpenter
@ 2020-04-08  4:33 ` Jiasen Lin
  0 siblings, 0 replies; 2+ messages in thread
From: Jiasen Lin @ 2020-04-08  4:33 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-ntb, zhangpanyong



On 2020/4/6 18:41, Dan Carpenter wrote:
> Hello Jiasen Lin,
> 
> This is a semi-automatic email about new static checker warnings.
> 
> The patch 99a06056124d: "NTB: ntb_perf: Fix address err in
> perf_copy_chunk" from Nov 20, 2019, leads to the following Smatch
> complaint:
> 
>      drivers/ntb/test/ntb_perf.c:1017 perf_clear_test()
>      warn: variable dereferenced before check 'pthr->dma_chan' (see line 1011)
> 
> drivers/ntb/test/ntb_perf.c
>    1010		 */
>    1011		(void)dmaengine_terminate_sync(pthr->dma_chan);
>                                                 ^^^^^^^^^^^^^^
> "pthr->dma_chan" is dereferenced inside the function.
> 
>    1012		if (pthr->perf->test_peer->dma_dst_addr)
>    1013			dma_unmap_resource(pthr->dma_chan->device->dev,
>    1014					   pthr->perf->test_peer->dma_dst_addr,
>    1015					   pthr->perf->test_peer->outbuf_size,
>    1016					   DMA_FROM_DEVICE, 0);
>    1017		if (pthr->dma_chan)
>                      ^^^^^^^^^^^^^^
> This new NULL check is too late.
Hi Dan
Nice catch!

As pthr->dma_chan can't be NULL in this context, so there is no need to 
check pthr->dma_chan.
Will fix it in next patch.

Thanks,
Jiasen Lin
> 
>    1018			dma_release_channel(pthr->dma_chan);
>    1019	
> 
> regards,
> dan carpenter
> 

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

end of thread, other threads:[~2020-04-08  4:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 10:41 [bug report] NTB: ntb_perf: Fix address err in perf_copy_chunk Dan Carpenter
2020-04-08  4:33 ` Jiasen Lin

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.