🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26750

Re: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries

#26750
From: Mahanta Jambigi
Date: Fri, 04 Dec 2026 05:30
43 lines
13954 bytes

On 04/12/26 8:12 am, Dust Li wrote:
> On 2026-12-03 13:50:08, Mahanta Jambigi wrote:
>> When a device coalesces the entries of a virtually contiguous buffer,
>> ib_dma_map_sg() maps fewer entries than requested and
>> smcr_buf_map_link() gives up with -EAGAIN. The error path frees the sg
>> table without unmapping it, so the DMA mapping is leaked.
>>
>> Take the existing buf_unmap path, which unmaps the sg table before
>> freeing it.
>>
>> Fixes: b8d199451c99 ("net/smc: Allow virtually contiguous sndbufs or RMBs for SMC-R")
>> Signed-off-by: Mahanta Jambigi <mjambigi@linux.ibm.com>
>> ---
>> net/smc/smc_core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
>> index a3164201c142..0561ef81102d 100644
>> --- a/net/smc/smc_core.c
>> +++ b/net/smc/smc_core.c
>> @@ -2226,7 +2226,7 @@ static int smcr_buf_map_link(struct smc_buf_desc *buf_desc, bool is_rmb,
>> 	/* SMC protocol depends on mapping to one DMA address only */
>> 	if (rc != nents) {
>> 		rc = -EAGAIN;
>> -		goto free_table;
>> +		goto buf_unmap;
>> 	}
> 
> Good catch! I think we should handle the error inside
> smc_ib_buf_map_sg() and clean up on failure so callers don't have to
> worry about those details.

Agreed, thanks. v2 moves the cleanup into smc_ib_buf_map_sg(): it
unmaps when ib_dma_map_sg() maps fewer entries than orig_nents and
returns -EAGAIN (or -ENOMEM when nothing was mapped), and returns 0 on
success. smcr_buf_map_link() now only frees the sg table on failure.

The helper's success return changes from the mapped count to 0; the
only caller is smcr_buf_map_link(), which keeps -EAGAIN for the rest of
the tree.
Technical Details
Message-ID: <562f5658-21cc-443b-bd14-5a02761b72ba@linux.ibm.com>
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ro.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377078-linux-kernel-netdev=dewy.ru
References: <20261203125008.2061833-1-mjambigi@linux.ibm.com> <axIojJfevGEol4BB@linux.alibaba.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ro.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377078-linux-kernel-netdev=dewy.ru
From: mjambigi@linux.ibm.com (Mahanta Jambigi)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces
 entries
Date: Fri, 4 Dec 2026 11:00:08 +0530
Organization: Usenet Network
Message-ID: <562f5658-21cc-443b-bd14-5a02761b72ba@linux.ibm.com>
References: <20261203125008.2061833-1-mjambigi@linux.ibm.com>
 <axIojJfevGEol4BB@linux.alibaba.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2682989"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:thPWWy5Y/wVuNwKkLrvyC3g6DXU= sha256:4Cvr7u6oi/PBt265LD2WzNfrrCkFf+KDPrw6v95GkCs=
	sha1:VEISRAtT2MLY7wZ50SFLLUW0D80= sha256:iYZLfMvkAeiVw3bT/Ap9UBD5kUjC29LD92FpZKdiCkc=
Content-Language: en-US
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 0F3DE117B07; Fri,  4 Dec 2026 08:30:52 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.299
X-Spam-Status: No, score=-3.299 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.001, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=ibm.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id W3SYl5ZsbUTk;
	Fri,  4 Dec 2026 08:30:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377078-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=linux.ibm.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 0D898116D9F; Fri,  4 Dec 2026 08:30:34 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id D0F512515E; Fri,  4 Dec 2026 05:30:32 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796362230;
	b=HSg+rsS2tKpC7RUSWTxFQGA6AVHKcavDa1QxbBzW5up2VyWLxK3IWu/AThFefTsexEMm
	 XNPmALvwjvxwsRp+vrT6TpEYZ/6ecMGReB9O3blJ60un3604XE+aqKjdogq9a/BflsrOz
	 kv7SzmEbUVQidK+l+dMym9hK4Vo1m38GOG7Td/OK0sfNE6E2JbQF7Ofy31EES5j4fqeuF
	 2MlzjqkGyyYV2oGA5BEF9J5CFT3jKcUAsqFojl4JXvPxAufavIQLdr1PRESPP6HYE0HDr
	 1CFzZ9voi3Uucexd+8EO/RPesjPPboB70NclUqpHfaxUBoZgp0gJMCjuwwZhfvHGszw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796362230;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:Received:
	 Received:Received:Received:Received:Received:Received:Message-ID:Date:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent:
	 Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding:X-TM-AS-GCONF:
	 X-Proofpoint-Reinject:X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID:
	 X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID:X-Authority-Analysis:
	 X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details;
	bh=961KZ292bQf0pBnFHxMvsn+OmSLzlnES35lP0mXun+k=;
	b=1Bngxni0xYExjj75nB1iA24NIgNW7OYw6FxQO0pEULljtBLLAH7ybonIlXLujp8Ed+qR
	 3CxITJD+QDBGRr56jy9COmnvJs6N930aso6YWav64iv7gWE3z1851nnCbCrFj9SBpmHCQ
	 mtXiPXLetfcwDCPxHaCVlVIezBFN8LZEAZ8zSa9IEg1SafPNyEmyoQm5BGqSm9H1j6DsH
	 xT29zHusej5t+f4uYyCvpLZZJbrhc6rxfyxjsLGdgBo2CjxANiuXtQiNhis7EzhyQ/YgS
	 cuy5iNbTvXAOXrQkJEMJjPm0NKs2WV1okOwYs+JC+IVRXNmvLIJVnLoTNGOZmDYZakQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b="oZ3lC/VS";
	dmarc=pass header.from=linux.ibm.com;
	spf=pass smtp.mailfrom=linux.ibm.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BEC8606A33A;
	Fri,  4 Dec 2026 05:30:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=oZ3lC/VS
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796362229;
	b=Q1h6IFuulMWrlzUzfhuc9wCF5JFqKH4xZVs970dGEGu8EDATesYEiCAjOYMHipwbzm4D
	 oU/oj0rJk/E9Kr/5Yy+vCLoDHymz9+HkNrrGTxoqo0J+FYFdWoDh8jkBZv0CEUWdouKZT
	 M5vrxTn4NKRlpcthFghU8YkrhW4Jt4byZIpHtcK2bmqbOtt4ZeL31FM6VT/RhvFJCZYd/
	 Y7ALVSbvHzHYNa2Od2KOCubGr2DPRSaoJuzMBzeRC/24ilGfa0s80u2Kkf99jJk8pY7V+
	 Z6QtMtNvAZV6ZNaChVbOQiE013S8KF6vJ8YXhe0fBOXGsQ7vIpx37i7TbzYGX7nbgaA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796362229;
	h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received:
	 Received:Received:Received:Received:Message-ID:Date:MIME-Version:
	 User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding:X-TM-AS-GCONF:
	 X-Proofpoint-Reinject:X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID:
	 X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID:X-Authority-Analysis:
	 X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details;
	bh=961KZ292bQf0pBnFHxMvsn+OmSLzlnES35lP0mXun+k=;
	b=dP9YrBNjkQEagsNtEC+w4S57eYLSryL+RkBSVeSAfkhvQ0SH3i8M2TmbrYEgZihXG8Ub
	 GoXEyg0z8SHZiSuCe+Ht32PR2DQ7j+IpyZPg1P9LXM0v8o7OrWoAdR+Ns3r1Z1B1ps/A8
	 lYlPi3xl+ew/448EvJYuOy1tbMah+mTB/xkZ8QH+yix6ThDvkvNUNEaZnkXNf/g0L3tSd
	 R74ELNr3w+2yrp/xfOu92L36ItOJL19Q5UknYtioUjvtsG3d6CxJ7+8Isum0UP/9HC+rk
	 wFCipB6zRWHLygvBul0n/gXIrhO85FIeay1kEdD7fwo1wHYiwgALPC42hfxDbkrxiUw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.ibm.com;
	spf=pass smtp.mailfrom=linux.ibm.com;
	dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b="oZ3lC/VS";
	arc=none smtp.remote-ip=148.163.156.1
X-Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAE20606A322;
	Fri,  4 Dec 2026 05:30:28 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EAE20606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com
X-Received: from pps.filterd (m0356517.ppops.net [127.0.0.1])
	by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B414bSn752517;
	Fri, 4 Dec 2026 05:30:22 GMT
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc
	:content-transfer-encoding:content-type:date:from:in-reply-to
	:message-id:mime-version:references:subject:to; s=pp1; bh=961KZ2
	92bQf0pBnFHxMvsn+OmSLzlnES35lP0mXun+k=; b=oZ3lC/VSrEHtNv3BAU8uMf
	mvXWyIzbAIwXv1n5G7tw8jNGXObIx7aw1ehhNiCLssSCGCpBT7SOYEF3PVo5efK/
	IzPvR/yN4c6lOy1eQaeuPR7cBFGElXYzdgoMf+1RG5UMiQDy0a5U4Ze+GazHv72m
	vC559uccbVE/clhndX8d2IZvbYKT1yynUENQAewC8QUwnmGvXTcRj1XAkSHuXEUu
	/nkZhlnWpF7MNlM/c9KTr3H0rY7y+xFdYwta3hk98MRNHAFWCa4kaFyBN3fmeAbi
	qzosxGAdWrliF4eRjJooeZ2QboGdk2fnwQ0Y8/549DtWZLGOY7VKdvJ0TzZ4C2Pw
	==
X-Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92])
	by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4jbgfd19j5-1
	(version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);
	Fri, 04 Dec 2026 05:30:20 +0000 (GMT)
X-Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1])
	by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B40nSOJ610005;
	Fri, 4 Dec 2026 05:30:20 GMT
X-Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74])
	by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4jaajshb1u-1
	(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);
	Fri, 04 Dec 2026 05:30:20 +0000 (GMT)
X-Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229])
	by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B45UIeY8913456
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);
	Fri, 4 Dec 2026 05:30:18 GMT
X-Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1])
	by IMSVA (Postfix) with ESMTP id 9D0E85805E;
	Fri,  4 Dec 2026 05:30:16 +0000 (GMT)
X-Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1])
	by IMSVA (Postfix) with ESMTP id 2E0805805F;
	Fri,  4 Dec 2026 05:30:10 +0000 (GMT)
X-Received: from [9.123.8.233] (unknown [9.123.8.233])
	by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP;
	Fri,  4 Dec 2026 05:30:09 +0000 (GMT)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Cc: hidayath@linux.ibm.com, pasic@linux.ibm.com, horms@kernel.org,
        tonylu@linux.alibaba.com, guwen@linux.alibaba.com,
        netdev@vger.kernel.org, linux-s390@vger.kernel.org,
        linux-rdma@vger.kernel.org, stable@vger.kernel.org
X-In-Reply-To: <axIojJfevGEol4BB@linux.alibaba.com>
X-TM-AS-GCONF: 00
X-Proofpoint-Reinject: loops=2 maxloops=12
X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYx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ut3YA:10
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49
 definitions=2026-12-04_01,2026-12-03_04,2025-10-01_01
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0
 suspectscore=0 spamscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0
 priorityscore=1501 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0
 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0
 reason=mlx scancount=1 engine=8.22.0-2612010000 definitions=main-2612040020