From: Leon Romanovsky <leon@kernel.org>
To: Jack Wang <jinpu.wang@ionos.com>
Cc: linux-kernel@vger.kernel.org, "Jason Gunthorpe" <jgg@ziepe.ca>,
"Christophe JAILLET" <christophe.jaillet@wanadoo.fr>,
"Kees Cook" <keescook@chromium.org>,
"Håkon Bugge" <haakon.bugge@oracle.com>,
linux-rdma@vger.kernel.org
Subject: Re: [PATCH v1 02/19] infiniband/mthca: Fix dma_map_sg error check
Date: Sun, 21 Aug 2022 14:46:43 +0300 [thread overview]
Message-ID: <YwIbI3ktmEiLsy6s@unreal> (raw)
In-Reply-To: <20220819060801.10443-3-jinpu.wang@ionos.com>
On Fri, Aug 19, 2022 at 08:07:44AM +0200, Jack Wang wrote:
> dma_map_sg return 0 on error, in case of error set
> EIO as return code.
>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: "Håkon Bugge" <haakon.bugge@oracle.com>
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
> ---
> drivers/infiniband/hw/mthca/mthca_memfree.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
> index f2734a5c5f26..44fd5fdf64d5 100644
> --- a/drivers/infiniband/hw/mthca/mthca_memfree.c
> +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
> @@ -189,7 +189,7 @@ struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages,
> chunk->npages,
> DMA_BIDIRECTIONAL);
>
> - if (chunk->nsg <= 0)
> + if (!chunk->nsg)
> goto fail;
> }
>
> @@ -208,7 +208,7 @@ struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages,
> chunk->nsg = dma_map_sg(&dev->pdev->dev, chunk->mem,
> chunk->npages, DMA_BIDIRECTIONAL);
>
> - if (chunk->nsg <= 0)
> + if (!chunk->nsg)
> goto fail;
> }
>
> @@ -482,8 +482,9 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
>
> ret = dma_map_sg(&dev->pdev->dev, &db_tab->page[i].mem, 1,
> DMA_TO_DEVICE);
> - if (ret < 0) {
> + if (!ret) {
This code is not equivalent to original code. mthca didn't count ret == 0
as an error. Most likely, it is a bug, but I don't want to change old and
unmaintained driver without any real need.
Thanks
> unpin_user_page(pages[0]);
> + ret = -EIO;
> goto out;
> }
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2022-08-21 11:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220819060801.10443-1-jinpu.wang@ionos.com>
2022-08-19 6:07 ` [PATCH v1 02/19] infiniband/mthca: Fix dma_map_sg error check Jack Wang
2022-08-19 22:19 ` Kees Cook
2022-08-21 11:46 ` Leon Romanovsky [this message]
2022-08-22 5:11 ` Dan Carpenter
2022-08-19 6:08 ` [PATCH v1 19/19] net/mlx4: Fix error check for dma_map_sg Jack Wang
2022-08-21 11:42 ` Leon Romanovsky
2022-08-22 18:20 ` Jakub Kicinski
2022-08-24 14:39 ` Jinpu Wang
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=YwIbI3ktmEiLsy6s@unreal \
--to=leon@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=haakon.bugge@oracle.com \
--cc=jgg@ziepe.ca \
--cc=jinpu.wang@ionos.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
/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