NTB: ntb_perf: Fix address err in perf_copy_chunk
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
Quoted 17 lines · Dan Carpenter
Hello Jiasen Lin,
This is a semi-automatic email about new static checker warnings.
The patch
99a06056124d: "NTB:ntb_perf: Fix address err inperf_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.
Quoted 8 lines
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
Quoted 7 lines
1018 dma_release_channel(pthr->dma_chan); 1019regards,
dan carpenter