Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: libcxgbi: Free the socket on error path in cxgbi_check_route6()
@ 2026-12-04  4:50 Haoxiang Li
  2026-12-04  5:19 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-12-04  4:50 UTC (permalink / raw)
  To: James.Bottomley, mkp, bvanassche, anish, manojmalviya, davem,
	kxie
  Cc: linux-scsi, Haoxiang Li

cxgbi_sock_create() allocates a socket and cpls. If later address
lookup fails, this memory is leaked. Free the cpl buffers and drop
the socket reference directly.

Fixes: fc8d0590d914 ("libcxgbi: Add ipv6 api to driver")
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
 drivers/scsi/cxgbi/libcxgbi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index b0bffbc38183..c77a01cdda24 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -820,8 +820,10 @@ cxgbi_check_route6(struct sockaddr *dst_addr, int ifindex)
 		neigh_release(n);
 
 	ip6_rt_put(rt);
-	if (csk)
-		cxgbi_sock_closed(csk);
+	if (csk) {
+		cxgbi_sock_free_cpl_skbs(csk);
+		cxgbi_sock_put(csk);
+	}
 err_out:
 	return ERR_PTR(err);
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: libcxgbi: Free the socket on error path in cxgbi_check_route6()
  2026-12-04  4:50 [PATCH] scsi: libcxgbi: Free the socket on error path in cxgbi_check_route6() Haoxiang Li
@ 2026-12-04  5:19 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-04  5:19 UTC (permalink / raw)
  To: Haoxiang Li; +Cc: linux-scsi

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] scsi: libcxgbi: resolve IPv6 saddr before cxgbi_sock_create()
- [Low] scsi: libcxgbi: changelog omits why cxgbi_sock_closed() leaked
  csk
--

commit 82ba5c15956713e1844bb776bd39db464c5fab3b
Author: Haoxiang Li <haoxiang_li2024@163.com>

> scsi: libcxgbi: Free the socket on error path in cxgbi_check_route6()
>
> cxgbi_sock_create() allocates a socket and cpls. If later address
> lookup fails, this memory is leaked. Free the cpl buffers and drop
> the socket reference directly.
>
> Fixes: fc8d0590d914 ("libcxgbi: Add ipv6 api to driver")
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>

[Severity: Low]
Could the changelog explain why the previous cxgbi_sock_closed() call
leaked the socket?  cxgbi_sock_create() initializes csk->state to
CTP_CLOSED, so cxgbi_sock_closed() returns early without freeing the
cpl skbs or dropping the reference.

> diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
> index b0bffbc381834..c77a01cdda24b 100644
> --- a/drivers/scsi/cxgbi/libcxgbi.c
> +++ b/drivers/scsi/cxgbi/libcxgbi.c
> @@ -820,8 +820,10 @@ cxgbi_check_route6(struct sockaddr *dst_addr, int ifindex)
>  		neigh_release(n);
>  
>  	ip6_rt_put(rt);
> -	if (csk)
> -		cxgbi_sock_closed(csk);
> +	if (csk) {
> +		cxgbi_sock_free_cpl_skbs(csk);
> +		cxgbi_sock_put(csk);
> +	}
>  err_out:
>  	return ERR_PTR(err);
>  }

[Severity: Low]
Would it be simpler to resolve pref_saddr before calling
cxgbi_sock_create(), as cxgbi_check_route() does for IPv4?

Neither rt6_get_prefsrc() nor ipv6_dev_get_saddr() depends on csk.
Moving the lookup earlier avoids allocating and freeing a cxgbi_sock and
its cpl skbs on lookup failure, and removes the need for the manual csk
teardown block here.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204045046.1447268-1-haoxiang_li2024@163.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04  5:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  4:50 [PATCH] scsi: libcxgbi: Free the socket on error path in cxgbi_check_route6() Haoxiang Li
2026-12-04  5:19 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox