Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Haoxiang Li" <haoxiang_li2024@163.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: libcxgbi: Free the socket on error path in cxgbi_check_route6()
Date: Fri, 04 Dec 2026 05:19:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-249125@kernel.org> (raw)
In-Reply-To: <20261204045046.1447268-1-haoxiang_li2024@163.com>

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

      reply	other threads:[~2026-12-04  5:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 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=sashiko-outbox-249125@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=haoxiang_li2024@163.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox