From: sashiko-bot@kernel.org
To: "Zhiping Zhang" <zhipingz@meta.com>
Cc: dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org,
kvm@vger.kernel.org
Subject: Re: [PATCH v6 5/5] RDMA/mlx5: get tph for p2p access when registering dma-buf mr
Date: Tue, 09 Jun 2026 19:38:40 +0000 [thread overview]
Message-ID: <20260609193841.0DD6E1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260608185646.4085127-6-zhipingz@meta.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the `mlx5r_create_mkeys` error rollback loop contains an off-by-one error. It leaks the successfully created hardware mkey at `handles[0]` and improperly attempts to destroy the uninitialized failed handle at `handles[i]`, which translates to destroying the reserved hardware mkey index 0.
--
commit 37ae7395b661b5e14306aec55bedd4ae96943e49
Author: Zhiping Zhang <zhipingz@meta.com>
RDMA/mlx5: get tph for p2p access when registering dma-buf mr
Query dma-buf TPH metadata when registering a dma-buf MR for peer-to-
peer access and translate the returned steering tag into an mlx5 ST
index. Keep the DMAH path as the first priority and only fall back to
DMA-buf metadata when no DMAH is supplied.
[ ... ]
> diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
> index 254e6aa4ccafb..7b0a883e04048 100644
> --- a/drivers/infiniband/hw/mlx5/mr.c
> +++ b/drivers/infiniband/hw/mlx5/mr.c
[ ... ]
> @@ -299,7 +331,8 @@ static int mlx5r_create_mkeys(struct ib_device *device, struct ib_frmr_key *key,
> return err;
> }
[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the changes
in mlx5r_create_mkeys(), I noticed an off-by-one error in the error
rollback loop right above this return statement.
The error rollback loop is written as:
if (err)
for (; i > 0; i--)
mlx5_core_destroy_mkey(dev->mdev, handles[i]);
Since the loop body operates on handles[i] and decrements afterward, doesn't
this terminate before i == 0, thereby skipping handles[0] and leaking the
first successfully created hardware mkey?
Additionally, is it safe to call mlx5_core_destroy_mkey() on the failed
handles[i] where the error occurred?
Because handles[i] only received an 8-bit variant via assign_mkey_variant()
and the firmware failed to populate its hardware index, its upper 24 bits
are zeroed. When mlx5_mkey_to_idx() extracts the upper 24 bits, it yields 0.
Could this cause the driver to inadvertently destroy mkey index 0, which is
a reserved hardware resource?
>
> -static void mlx5r_destroy_mkeys(struct ib_device *device, u32 *handles,
> +static void mlx5r_destroy_mkeys(struct ib_device *device,
> + const struct ib_frmr_key *key, u32 *handles,
> unsigned int count)
> {
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260608185646.4085127-1-zhipingz@meta.com?part=5
prev parent reply other threads:[~2026-06-09 19:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 18:56 [PATCH v6 0/5] vfio/dma-buf: add TPH support for peer-to-peer access Zhiping Zhang
2026-06-08 18:56 ` [PATCH v6 1/5] net/mlx5: free mlx5_st_idx_data on final dealloc Zhiping Zhang
2026-06-08 18:56 ` [PATCH v6 2/5] PCI/TPH: expose enabled requester type and capability helpers Zhiping Zhang
2026-06-09 19:56 ` Bjorn Helgaas
2026-06-09 23:38 ` Zhiping Zhang
2026-06-08 18:56 ` [PATCH v6 3/5] dma-buf: add optional get_tph() callback Zhiping Zhang
2026-06-09 8:10 ` Christian König
2026-06-09 14:38 ` Zhiping Zhang
2026-06-09 19:38 ` sashiko-bot
2026-06-08 18:56 ` [PATCH v6 4/5] vfio/pci: implement get_tph and DMA_BUF_TPH feature Zhiping Zhang
2026-06-09 8:12 ` Christian König
2026-06-09 14:39 ` Zhiping Zhang
2026-06-09 19:38 ` sashiko-bot
2026-06-09 21:46 ` Alex Williamson
2026-06-09 23:48 ` Zhiping Zhang
2026-06-08 18:56 ` [PATCH v6 5/5] RDMA/mlx5: get tph for p2p access when registering dma-buf mr Zhiping Zhang
2026-06-09 19:38 ` sashiko-bot [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=20260609193841.0DD6E1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhipingz@meta.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 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.