* re: NTB: Use unique DMA channels for TX and RX
@ 2015-09-16 14:12 Dan Carpenter
2015-09-16 14:41 ` Allen Hubbe
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2015-09-16 14:12 UTC (permalink / raw)
To: dave.jiang; +Cc: linux-ntb
Hello Dave Jiang,
This is a semi-automatic email about new static checker warnings.
The patch 569410ca756c: "NTB: Use unique DMA channels for TX and RX"
from Jul 13, 2015, leads to the following Smatch complaint:
drivers/ntb/ntb_transport.c:2008 ntb_transport_max_size()
error: we previously assumed 'qp->tx_dma_chan' could be null (see line 2005)
drivers/ntb/ntb_transport.c
2004
2005 if (!qp->tx_dma_chan && !qp->rx_dma_chan)
Patch adds new checks for NULL. Was || intended here perhaps?
2006 return qp->tx_max_frame - sizeof(struct ntb_payload_header);
2007
2008 copy_align = max(qp->tx_dma_chan->device->copy_align,
2009 qp->rx_dma_chan->device->copy_align);
Patch adds unchecked dereferences.
2010
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: NTB: Use unique DMA channels for TX and RX
2015-09-16 14:12 NTB: Use unique DMA channels for TX and RX Dan Carpenter
@ 2015-09-16 14:41 ` Allen Hubbe
0 siblings, 0 replies; 2+ messages in thread
From: Allen Hubbe @ 2015-09-16 14:41 UTC (permalink / raw)
To: dave.jiang; +Cc: linux-ntb
From: linux-ntb@googlegroups.com On Behalf Of Dan Carpenter
> Subject: re: NTB: Use unique DMA channels for TX and RX
>
> drivers/ntb/ntb_transport.c:2008 ntb_transport_max_size()
> error: we previously assumed 'qp->tx_dma_chan' could be null (see
> line 2005)
>
> drivers/ntb/ntb_transport.c
> 2004
> 2005 if (!qp->tx_dma_chan && !qp->rx_dma_chan)
I seem to recall commenting on this in patch v1:
>> - if (!qp->dma_chan)
>> + if (!qp->tx_dma_chan && !qp->rx_dma_chan)
>
> Unusual to see "if (not && not)" in code, but it looks correct in this case.
>
> if (no dma at all)
> return without any alignment restriction;
>
> Is that right?
Maybe I was wrong to say "looks correct" because this static checker warning sure looks real.
>
> Patch adds new checks for NULL. Was || intended here perhaps?
>
> 2006 return qp->tx_max_frame - sizeof(struct
> ntb_payload_header);
> 2007
> 2008 copy_align = max(qp->tx_dma_chan->device->copy_align,
> 2009 qp->rx_dma_chan->device->copy_align);
I think this is the part that actually needs to be fixed. Maybe this whole function should be:
copy_align = max(dma_copy_align(qp->tx_dma_chan),
dma_copy_align(qp->rx_dma_chan));
where dma_copy_align is:
if (!chan)
return 1;
return chan->device->copy_align;
>
> Patch adds unchecked dereferences.
>
> 2010
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-16 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-16 14:12 NTB: Use unique DMA channels for TX and RX Dan Carpenter
2015-09-16 14:41 ` Allen Hubbe
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.