All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mahanta Jambigi <mjambigi@linux.ibm.com>
To: Wentao Liang <vulab@iscas.ac.cn>,
	"D. Wythe" <alibuda@linux.alibaba.com>,
	Dust Li <dust.li@linux.alibaba.com>,
	Sidraya Jayagond <sidraya@linux.ibm.com>,
	Tony Lu <tonylu@linux.alibaba.com>,
	Wen Gu <guwen@linux.alibaba.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>
Cc: linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH] net/smc: deregister the MR when SG mapping fails
Date: Thu, 5 Nov 2026 15:20:09 +0530	[thread overview]
Message-ID: <78beaf8e-6357-4856-8464-717bb47d74a4@linux.ibm.com> (raw)
In-Reply-To: <20261104022812.1484233-1-vulab@iscas.ac.cn>

Going forward Subject should mentioned PATCH net.

On 04/11/26 7:58 am, Wentao Liang wrote:
> When smc_ib_map_mr_sg() maps fewer entries than the SG table holds,
> smc_ib_get_memory_region() returns -EINVAL with the memory region
> still allocated and its pointer left in buf_slot->mr[link_idx].
> The caller only undoes the DMA mapping and frees the SG table, and
> because buf_desc->is_map_ib[] is set only after this function
> succeeds, smcr_buf_unmap_link() later skips the buffer.  Both the
> MR and the pd->usecnt reference taken by ib_alloc_mr() are lost.
> 
> The stale pointer is also harmful: a retry takes the "already done"
> shortcut and treats a memory region that was never mapped as valid.
> 
> Deregister the memory region and clear the slot before returning.
> 
> Fixes: 897e1c245773 ("net/smc: use separate memory regions for RMBs")
> Cc: stable@vger.kernel.org
> Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex

This is not required.

> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>

Reviewed-by: Mahanta Jambigi <mjambigi@linux.ibm.com>

> ---
>  net/smc/smc_ib.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
> index daaa8a72da90..fa21d269196e 100644
> --- a/net/smc/smc_ib.c
> +++ b/net/smc/smc_ib.c
> @@ -735,8 +735,11 @@ int smc_ib_get_memory_region(struct ib_pd *pd, int access_flags,
>  	}
>  
>  	if (smc_ib_map_mr_sg(buf_slot, link_idx) !=
> -			     buf_slot->sgt[link_idx].orig_nents)
> +			     buf_slot->sgt[link_idx].orig_nents) {
> +		smc_ib_put_memory_region(buf_slot->mr[link_idx]);
> +		buf_slot->mr[link_idx] = NULL;
>  		return -EINVAL;
> +	}
>  
>  	return 0;
>  }


      parent reply	other threads:[~2026-11-05  9:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  2:28 [PATCH] net/smc: deregister the MR when SG mapping fails Wentao Liang
2026-11-04  2:32 ` netdev-bot+sinfo
2026-11-05  8:54 ` Dust Li
2026-11-05  9:50 ` Mahanta Jambigi [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=78beaf8e-6357-4856-8464-717bb47d74a4@linux.ibm.com \
    --to=mjambigi@linux.ibm.com \
    --cc=alibuda@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@kernel.org \
    --cc=guwen@linux.alibaba.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sidraya@linux.ibm.com \
    --cc=tonylu@linux.alibaba.com \
    --cc=vulab@iscas.ac.cn \
    /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.