* Re: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries
2026-12-03 12:50 [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries Mahanta Jambigi
@ 2026-12-03 12:53 ` netdev-bot+sinfo
2026-12-04 2:42 ` Dust Li
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sinfo @ 2026-12-03 12:53 UTC (permalink / raw)
To: Mahanta Jambigi
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, alibuda, dust.li,
sidraya, hidayath, pasic, horms, tonylu, guwen, netdev,
linux-s390, linux-rdma, stable
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries
2026-12-03 12:50 [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries Mahanta Jambigi
2026-12-03 12:53 ` netdev-bot+sinfo
@ 2026-12-04 2:42 ` Dust Li
2026-12-04 5:30 ` Mahanta Jambigi
2026-12-04 3:46 ` kernel test robot
` (2 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Dust Li @ 2026-12-04 2:42 UTC (permalink / raw)
To: Mahanta Jambigi, andrew+netdev, davem, edumazet, kuba, pabeni,
alibuda, sidraya
Cc: hidayath, pasic, horms, tonylu, guwen, netdev, linux-s390,
linux-rdma, stable
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.
Best regards,
Dust
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries
2026-12-04 2:42 ` Dust Li
@ 2026-12-04 5:30 ` Mahanta Jambigi
0 siblings, 0 replies; 7+ messages in thread
From: Mahanta Jambigi @ 2026-12-04 5:30 UTC (permalink / raw)
To: dust.li, andrew+netdev, davem, edumazet, kuba, pabeni, alibuda,
sidraya
Cc: hidayath, pasic, horms, tonylu, guwen, netdev, linux-s390,
linux-rdma, stable
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries
2026-12-03 12:50 [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries Mahanta Jambigi
2026-12-03 12:53 ` netdev-bot+sinfo
2026-12-04 2:42 ` Dust Li
@ 2026-12-04 3:46 ` kernel test robot
2026-12-04 5:06 ` kernel test robot
2026-12-04 12:53 ` sashiko-bot
4 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2026-12-04 3:46 UTC (permalink / raw)
To: Mahanta Jambigi, andrew+netdev, davem, edumazet, kuba, pabeni,
alibuda, dust.li, sidraya
Cc: llvm, oe-kbuild-all, hidayath, pasic, horms, tonylu, guwen,
netdev, linux-s390, linux-rdma, stable, Mahanta Jambigi
Hi Mahanta,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Mahanta-Jambigi/net-smc-unmap-the-sg-table-when-a-DMA-map-coalesces-entries/20261203-135008
base: net/main
patch link: https://lore.kernel.org/r/20261203125008.2061833-1-mjambigi%40linux.ibm.com
patch subject: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries
config: s390-defconfig (https://download.01.org/0day-ci/archive/20261204/20261204113916.iaJ6lBor-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261204/20261204113916.iaJ6lBor-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261204113916.iaJ6lBor-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> net/smc/smc_core.c:2254:1: warning: unused label 'free_table' [-Wunused-label]
2254 | free_table:
| ^~~~~~~~~~~
1 warning generated.
vim +/free_table +2254 net/smc/smc_core.c
952310ccf2d8619 Ursula Braun 2017-01-09 2183
b8d199451c99b37 Wen Gu 2022-07-14 2184 /* map an buf to a link */
b9247544c1bccfe Karsten Graul 2020-04-29 2185 static int smcr_buf_map_link(struct smc_buf_desc *buf_desc, bool is_rmb,
b9247544c1bccfe Karsten Graul 2020-04-29 2186 struct smc_link *lnk)
cd6851f30386e5e Ursula Braun 2017-01-09 2187 {
b8d199451c99b37 Wen Gu 2022-07-14 2188 int rc, i, nents, offset, buf_size, size, access_flags;
b8d199451c99b37 Wen Gu 2022-07-14 2189 struct scatterlist *sg;
b8d199451c99b37 Wen Gu 2022-07-14 2190 void *buf;
cd6851f30386e5e Ursula Braun 2017-01-09 2191
b9247544c1bccfe Karsten Graul 2020-04-29 2192 if (buf_desc->is_map_ib[lnk->link_idx])
b9247544c1bccfe Karsten Graul 2020-04-29 2193 return 0;
a3fe3d01bd0d7cd Ursula Braun 2017-07-28 2194
b8d199451c99b37 Wen Gu 2022-07-14 2195 if (buf_desc->is_vm) {
b8d199451c99b37 Wen Gu 2022-07-14 2196 buf = buf_desc->cpu_addr;
b8d199451c99b37 Wen Gu 2022-07-14 2197 buf_size = buf_desc->len;
b8d199451c99b37 Wen Gu 2022-07-14 2198 offset = offset_in_page(buf_desc->cpu_addr);
b8d199451c99b37 Wen Gu 2022-07-14 2199 nents = PAGE_ALIGN(buf_size + offset) / PAGE_SIZE;
b8d199451c99b37 Wen Gu 2022-07-14 2200 } else {
b8d199451c99b37 Wen Gu 2022-07-14 2201 nents = 1;
b8d199451c99b37 Wen Gu 2022-07-14 2202 }
b8d199451c99b37 Wen Gu 2022-07-14 2203
b8d199451c99b37 Wen Gu 2022-07-14 2204 rc = sg_alloc_table(&buf_desc->sgt[lnk->link_idx], nents, GFP_KERNEL);
b9247544c1bccfe Karsten Graul 2020-04-29 2205 if (rc)
b9247544c1bccfe Karsten Graul 2020-04-29 2206 return rc;
b8d199451c99b37 Wen Gu 2022-07-14 2207
b8d199451c99b37 Wen Gu 2022-07-14 2208 if (buf_desc->is_vm) {
b8d199451c99b37 Wen Gu 2022-07-14 2209 /* virtually contiguous buffer */
b8d199451c99b37 Wen Gu 2022-07-14 2210 for_each_sg(buf_desc->sgt[lnk->link_idx].sgl, sg, nents, i) {
b8d199451c99b37 Wen Gu 2022-07-14 2211 size = min_t(int, PAGE_SIZE - offset, buf_size);
b8d199451c99b37 Wen Gu 2022-07-14 2212 sg_set_page(sg, vmalloc_to_page(buf), size, offset);
10bc9761d12e440 Dan Carpenter 2025-01-08 2213 buf += size;
b8d199451c99b37 Wen Gu 2022-07-14 2214 buf_size -= size;
b8d199451c99b37 Wen Gu 2022-07-14 2215 offset = 0;
b8d199451c99b37 Wen Gu 2022-07-14 2216 }
b8d199451c99b37 Wen Gu 2022-07-14 2217 } else {
b8d199451c99b37 Wen Gu 2022-07-14 2218 /* physically contiguous buffer */
387707fdf48697c Karsten Graul 2020-04-29 2219 sg_set_buf(buf_desc->sgt[lnk->link_idx].sgl,
b9247544c1bccfe Karsten Graul 2020-04-29 2220 buf_desc->cpu_addr, buf_desc->len);
b8d199451c99b37 Wen Gu 2022-07-14 2221 }
a3fe3d01bd0d7cd Ursula Braun 2017-07-28 2222
3e034725c0d8143 Ursula Braun 2017-07-28 2223 /* map sg table to DMA address */
387707fdf48697c Karsten Graul 2020-04-29 2224 rc = smc_ib_buf_map_sg(lnk, buf_desc,
b33982c3a6838d1 Ursula Braun 2017-07-28 2225 is_rmb ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
3e034725c0d8143 Ursula Braun 2017-07-28 2226 /* SMC protocol depends on mapping to one DMA address only */
b8d199451c99b37 Wen Gu 2022-07-14 2227 if (rc != nents) {
b9247544c1bccfe Karsten Graul 2020-04-29 2228 rc = -EAGAIN;
489cce6c25f0fab Mahanta Jambigi 2026-12-03 2229 goto buf_unmap;
cd6851f30386e5e Ursula Braun 2017-01-09 2230 }
3e034725c0d8143 Ursula Braun 2017-07-28 2231
0ef69e788411cba Guangguan Wang 2022-07-14 2232 buf_desc->is_dma_need_sync |=
0ef69e788411cba Guangguan Wang 2022-07-14 2233 smc_ib_is_sg_need_sync(lnk, buf_desc) << lnk->link_idx;
0ef69e788411cba Guangguan Wang 2022-07-14 2234
b8d199451c99b37 Wen Gu 2022-07-14 2235 if (is_rmb || buf_desc->is_vm) {
b8d199451c99b37 Wen Gu 2022-07-14 2236 /* create a new memory region for the RMB or vzalloced sndbuf */
b8d199451c99b37 Wen Gu 2022-07-14 2237 access_flags = is_rmb ?
b8d199451c99b37 Wen Gu 2022-07-14 2238 IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE :
b8d199451c99b37 Wen Gu 2022-07-14 2239 IB_ACCESS_LOCAL_WRITE;
b8d199451c99b37 Wen Gu 2022-07-14 2240
b8d199451c99b37 Wen Gu 2022-07-14 2241 rc = smc_ib_get_memory_region(lnk->roce_pd, access_flags,
387707fdf48697c Karsten Graul 2020-04-29 2242 buf_desc, lnk->link_idx);
b9247544c1bccfe Karsten Graul 2020-04-29 2243 if (rc)
b9247544c1bccfe Karsten Graul 2020-04-29 2244 goto buf_unmap;
b8d199451c99b37 Wen Gu 2022-07-14 2245 smc_ib_sync_sg_for_device(lnk, buf_desc,
b8d199451c99b37 Wen Gu 2022-07-14 2246 is_rmb ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
b33982c3a6838d1 Ursula Braun 2017-07-28 2247 }
b9247544c1bccfe Karsten Graul 2020-04-29 2248 buf_desc->is_map_ib[lnk->link_idx] = true;
b9247544c1bccfe Karsten Graul 2020-04-29 2249 return 0;
b9247544c1bccfe Karsten Graul 2020-04-29 2250
b9247544c1bccfe Karsten Graul 2020-04-29 2251 buf_unmap:
b9247544c1bccfe Karsten Graul 2020-04-29 2252 smc_ib_buf_unmap_sg(lnk, buf_desc,
b9247544c1bccfe Karsten Graul 2020-04-29 2253 is_rmb ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
b9247544c1bccfe Karsten Graul 2020-04-29 @2254 free_table:
b9247544c1bccfe Karsten Graul 2020-04-29 2255 sg_free_table(&buf_desc->sgt[lnk->link_idx]);
b9247544c1bccfe Karsten Graul 2020-04-29 2256 return rc;
897e1c245773d93 Ursula Braun 2017-07-28 2257 }
b33982c3a6838d1 Ursula Braun 2017-07-28 2258
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries
2026-12-03 12:50 [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries Mahanta Jambigi
` (2 preceding siblings ...)
2026-12-04 3:46 ` kernel test robot
@ 2026-12-04 5:06 ` kernel test robot
2026-12-04 12:53 ` sashiko-bot
4 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2026-12-04 5:06 UTC (permalink / raw)
To: Mahanta Jambigi, andrew+netdev, davem, edumazet, kuba, pabeni,
alibuda, dust.li, sidraya
Cc: oe-kbuild-all, hidayath, pasic, horms, tonylu, guwen, netdev,
linux-s390, linux-rdma, stable, Mahanta Jambigi
Hi Mahanta,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net/main]
url: https://github.com/intel-lab-lkp/linux/commits/Mahanta-Jambigi/net-smc-unmap-the-sg-table-when-a-DMA-map-coalesces-entries/20261203-135008
base: net/main
patch link: https://lore.kernel.org/r/20261203125008.2061833-1-mjambigi%40linux.ibm.com
patch subject: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries
config: x86_64-rhel-9.4-bpf (https://download.01.org/0day-ci/archive/20261204/20261204130347.gF7vPNHv-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261204/20261204130347.gF7vPNHv-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261204130347.gF7vPNHv-lkp@intel.com/
All warnings (new ones prefixed by >>):
net/smc/smc_core.c: In function 'smcr_buf_map_link':
>> net/smc/smc_core.c:2254:1: warning: label 'free_table' defined but not used [-Wunused-label]
2254 | free_table:
| ^~~~~~~~~~
vim +/free_table +2254 net/smc/smc_core.c
952310ccf2d8619 Ursula Braun 2017-01-09 2183
b8d199451c99b37 Wen Gu 2022-07-14 2184 /* map an buf to a link */
b9247544c1bccfe Karsten Graul 2020-04-29 2185 static int smcr_buf_map_link(struct smc_buf_desc *buf_desc, bool is_rmb,
b9247544c1bccfe Karsten Graul 2020-04-29 2186 struct smc_link *lnk)
cd6851f30386e5e Ursula Braun 2017-01-09 2187 {
b8d199451c99b37 Wen Gu 2022-07-14 2188 int rc, i, nents, offset, buf_size, size, access_flags;
b8d199451c99b37 Wen Gu 2022-07-14 2189 struct scatterlist *sg;
b8d199451c99b37 Wen Gu 2022-07-14 2190 void *buf;
cd6851f30386e5e Ursula Braun 2017-01-09 2191
b9247544c1bccfe Karsten Graul 2020-04-29 2192 if (buf_desc->is_map_ib[lnk->link_idx])
b9247544c1bccfe Karsten Graul 2020-04-29 2193 return 0;
a3fe3d01bd0d7cd Ursula Braun 2017-07-28 2194
b8d199451c99b37 Wen Gu 2022-07-14 2195 if (buf_desc->is_vm) {
b8d199451c99b37 Wen Gu 2022-07-14 2196 buf = buf_desc->cpu_addr;
b8d199451c99b37 Wen Gu 2022-07-14 2197 buf_size = buf_desc->len;
b8d199451c99b37 Wen Gu 2022-07-14 2198 offset = offset_in_page(buf_desc->cpu_addr);
b8d199451c99b37 Wen Gu 2022-07-14 2199 nents = PAGE_ALIGN(buf_size + offset) / PAGE_SIZE;
b8d199451c99b37 Wen Gu 2022-07-14 2200 } else {
b8d199451c99b37 Wen Gu 2022-07-14 2201 nents = 1;
b8d199451c99b37 Wen Gu 2022-07-14 2202 }
b8d199451c99b37 Wen Gu 2022-07-14 2203
b8d199451c99b37 Wen Gu 2022-07-14 2204 rc = sg_alloc_table(&buf_desc->sgt[lnk->link_idx], nents, GFP_KERNEL);
b9247544c1bccfe Karsten Graul 2020-04-29 2205 if (rc)
b9247544c1bccfe Karsten Graul 2020-04-29 2206 return rc;
b8d199451c99b37 Wen Gu 2022-07-14 2207
b8d199451c99b37 Wen Gu 2022-07-14 2208 if (buf_desc->is_vm) {
b8d199451c99b37 Wen Gu 2022-07-14 2209 /* virtually contiguous buffer */
b8d199451c99b37 Wen Gu 2022-07-14 2210 for_each_sg(buf_desc->sgt[lnk->link_idx].sgl, sg, nents, i) {
b8d199451c99b37 Wen Gu 2022-07-14 2211 size = min_t(int, PAGE_SIZE - offset, buf_size);
b8d199451c99b37 Wen Gu 2022-07-14 2212 sg_set_page(sg, vmalloc_to_page(buf), size, offset);
10bc9761d12e440 Dan Carpenter 2025-01-08 2213 buf += size;
b8d199451c99b37 Wen Gu 2022-07-14 2214 buf_size -= size;
b8d199451c99b37 Wen Gu 2022-07-14 2215 offset = 0;
b8d199451c99b37 Wen Gu 2022-07-14 2216 }
b8d199451c99b37 Wen Gu 2022-07-14 2217 } else {
b8d199451c99b37 Wen Gu 2022-07-14 2218 /* physically contiguous buffer */
387707fdf48697c Karsten Graul 2020-04-29 2219 sg_set_buf(buf_desc->sgt[lnk->link_idx].sgl,
b9247544c1bccfe Karsten Graul 2020-04-29 2220 buf_desc->cpu_addr, buf_desc->len);
b8d199451c99b37 Wen Gu 2022-07-14 2221 }
a3fe3d01bd0d7cd Ursula Braun 2017-07-28 2222
3e034725c0d8143 Ursula Braun 2017-07-28 2223 /* map sg table to DMA address */
387707fdf48697c Karsten Graul 2020-04-29 2224 rc = smc_ib_buf_map_sg(lnk, buf_desc,
b33982c3a6838d1 Ursula Braun 2017-07-28 2225 is_rmb ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
3e034725c0d8143 Ursula Braun 2017-07-28 2226 /* SMC protocol depends on mapping to one DMA address only */
b8d199451c99b37 Wen Gu 2022-07-14 2227 if (rc != nents) {
b9247544c1bccfe Karsten Graul 2020-04-29 2228 rc = -EAGAIN;
489cce6c25f0fab Mahanta Jambigi 2026-12-03 2229 goto buf_unmap;
cd6851f30386e5e Ursula Braun 2017-01-09 2230 }
3e034725c0d8143 Ursula Braun 2017-07-28 2231
0ef69e788411cba Guangguan Wang 2022-07-14 2232 buf_desc->is_dma_need_sync |=
0ef69e788411cba Guangguan Wang 2022-07-14 2233 smc_ib_is_sg_need_sync(lnk, buf_desc) << lnk->link_idx;
0ef69e788411cba Guangguan Wang 2022-07-14 2234
b8d199451c99b37 Wen Gu 2022-07-14 2235 if (is_rmb || buf_desc->is_vm) {
b8d199451c99b37 Wen Gu 2022-07-14 2236 /* create a new memory region for the RMB or vzalloced sndbuf */
b8d199451c99b37 Wen Gu 2022-07-14 2237 access_flags = is_rmb ?
b8d199451c99b37 Wen Gu 2022-07-14 2238 IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE :
b8d199451c99b37 Wen Gu 2022-07-14 2239 IB_ACCESS_LOCAL_WRITE;
b8d199451c99b37 Wen Gu 2022-07-14 2240
b8d199451c99b37 Wen Gu 2022-07-14 2241 rc = smc_ib_get_memory_region(lnk->roce_pd, access_flags,
387707fdf48697c Karsten Graul 2020-04-29 2242 buf_desc, lnk->link_idx);
b9247544c1bccfe Karsten Graul 2020-04-29 2243 if (rc)
b9247544c1bccfe Karsten Graul 2020-04-29 2244 goto buf_unmap;
b8d199451c99b37 Wen Gu 2022-07-14 2245 smc_ib_sync_sg_for_device(lnk, buf_desc,
b8d199451c99b37 Wen Gu 2022-07-14 2246 is_rmb ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
b33982c3a6838d1 Ursula Braun 2017-07-28 2247 }
b9247544c1bccfe Karsten Graul 2020-04-29 2248 buf_desc->is_map_ib[lnk->link_idx] = true;
b9247544c1bccfe Karsten Graul 2020-04-29 2249 return 0;
b9247544c1bccfe Karsten Graul 2020-04-29 2250
b9247544c1bccfe Karsten Graul 2020-04-29 2251 buf_unmap:
b9247544c1bccfe Karsten Graul 2020-04-29 2252 smc_ib_buf_unmap_sg(lnk, buf_desc,
b9247544c1bccfe Karsten Graul 2020-04-29 2253 is_rmb ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
b9247544c1bccfe Karsten Graul 2020-04-29 @2254 free_table:
b9247544c1bccfe Karsten Graul 2020-04-29 2255 sg_free_table(&buf_desc->sgt[lnk->link_idx]);
b9247544c1bccfe Karsten Graul 2020-04-29 2256 return rc;
897e1c245773d93 Ursula Braun 2017-07-28 2257 }
b33982c3a6838d1 Ursula Braun 2017-07-28 2258
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries
2026-12-03 12:50 [PATCH net] net/smc: unmap the sg table when a DMA map coalesces entries Mahanta Jambigi
` (3 preceding siblings ...)
2026-12-04 5:06 ` kernel test robot
@ 2026-12-04 12:53 ` sashiko-bot
4 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-12-04 12:53 UTC (permalink / raw)
To: Mahanta Jambigi
Cc: linux-s390, linux-rdma, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] net/smc: smcr_buf_map_link() unmaps sg table on DMA mapping
failure
- [Medium] net/smc: unused free_table label in smcr_buf_map_link()
breaks build
--
commit 9210b3d201b780d3ddbcb843ac69fe3f41a1f09e
Author: Mahanta Jambigi <mjambigi@linux.ibm.com>
net/smc: unmap the sg table when a DMA map coalesces entries
This commit changes the rc != nents error path in smcr_buf_map_link() to
jump to buf_unmap instead of free_table so that coalesced sg mappings
are unmapped before freeing the sg table.
> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
> index a3164201c1420..0561ef81102d9 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;
> }
>
> buf_desc->is_dma_need_sync |=
[Severity: High]
Does this call smc_ib_buf_unmap_sg() on an unmapped scatterlist when
ib_dma_map_sg() fails?
smc_ib_buf_map_sg() returns -ENOMEM when ib_dma_map_sg() fails, which
also takes the rc != nents branch. smc_ib_buf_unmap_sg() only skips
unmapping when sgl->dma_address is 0, but iommu_dma_map_sg() and
dma_direct_map_sg() leave DMA_MAPPING_ERROR or rolled-back addresses.
Calling ib_dma_unmap_sg() on that scatterlist violates the DMA API,
triggering CONFIG_DMA_API_DEBUG errors and double-unmapping SWIOTLB
slots or IOVAs. Jumping to free_table when rc < 0 and only to buf_unmap
when rc > 0 avoids unmapping a failed mapping.
[Severity: Medium]
Will removing the only jump to free_table leave an unused label in
smcr_buf_map_link()?
With -Wall enabled in kernel builds, this triggers a -Wunused-label
warning and fails compilation under CONFIG_WERROR=y. Keeping the
free_table target for the rc < 0 path above resolves this as well.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203125008.2061833-1-mjambigi@linux.ibm.com?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread