From: Jon Mason <jdmason@kudzu.us>
To: Logan Gunthorpe <logang@deltatee.com>
Cc: linux-ntb@googlegroups.com, Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH] NTB: ntb_transport: Ensure qp->tx_mw_dma_addr is initaliazed
Date: Wed, 20 Mar 2019 14:17:10 -0400 [thread overview]
Message-ID: <20190320181709.GA1201@kudzu.us> (raw)
In-Reply-To: <20190219195636.1485-1-logang@deltatee.com>
On Tue, Feb 19, 2019 at 12:56:36PM -0700, Logan Gunthorpe wrote:
> Dan Carpenter's static checker reported:
>
> drivers/ntb/ntb_transport.c:1926 ntb_transport_create_queue()
> error: we previously assumed 'qp->tx_dma_chan' could be null (see line 1872)
>
> This is because the tx_mw_dma_addr is uninitialized in this function and
> may be incorrectly released using a NULL DMA channel.
>
> In practice this bug will not likely be seen. I'd guess you could hit
> this if you loaded ntb_netdev with use_dma=True, then unloaded it and
> loaded it again after setting the module parameter to use_dma=False.
>
> To fix this, we simply ensure that tx_mw_dma_addr is always
> initialized to zero. This is the safest in case any other part of the
> code operates on it if it is non-zero.
>
> Fixes: c27ccb899219 ("NTB: ntb_transport: Ensure the destination buffer is mapped for TX DMA")
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> Cc: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: Jon Mason <jdmason@kudzu.us>
Included in the ntb branch.
Thanks,
Jon
> ---
> drivers/ntb/ntb_transport.c | 1 +
> 1 file changed, 1 insertion(+)
>
> @Jon, it would be best if you can squash this with the commit that
> introduced the bug in ntb-next. Thanks.
>
> diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c
> index 526b65afc16a..e8a8304a42df 100644
> --- a/drivers/ntb/ntb_transport.c
> +++ b/drivers/ntb/ntb_transport.c
> @@ -1866,6 +1866,7 @@ ntb_transport_create_queue(void *data, struct device *client_dev,
> qp->rx_dma_chan = NULL;
> }
>
> + qp->tx_mw_dma_addr = 0;
> if (qp->tx_dma_chan) {
> qp->tx_mw_dma_addr =
> dma_map_resource(qp->tx_dma_chan->device->dev,
> --
> 2.19.0
prev parent reply other threads:[~2019-03-20 18:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-19 19:56 [PATCH] NTB: ntb_transport: Ensure qp->tx_mw_dma_addr is initaliazed Logan Gunthorpe
2019-03-20 18:17 ` Jon Mason [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190320181709.GA1201@kudzu.us \
--to=jdmason@kudzu.us \
--cc=dan.carpenter@oracle.com \
--cc=linux-ntb@googlegroups.com \
--cc=logang@deltatee.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox