From: Mike Christie <michael.christie@oracle.com>
To: linmq006@gmail.com, Lee Duncan <lduncan@suse.com>,
Chris Leech <cleech@redhat.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Lin Ma <linma@zju.edu.cn>,
open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: iscsi: Fix missing scsi_host_put in error path
Date: Mon, 24 Mar 2025 22:03:24 -0500 [thread overview]
Message-ID: <9dfb46b3-3dfe-40ea-9eae-c6a2533ad950@oracle.com> (raw)
In-Reply-To: <20250318094344.91776-1-linmq006@gmail.com>
On 3/18/25 4:43 AM, linmq006@gmail.com wrote:
> From: Miaoqian Lin <linmq006@gmail.com>
>
> Add goto to ensure scsi_host_put is called in all error paths of
> iscsi_set_host_param function. This fixes a potential memory leak when
> strlen check fails.
>
> Fixes: ce51c8170084 ("scsi: iscsi: Add strlen() check in iscsi_if_set{_host}_param()")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> drivers/scsi/scsi_transport_iscsi.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
> index 9c347c64c315..0b8c91bf793f 100644
> --- a/drivers/scsi/scsi_transport_iscsi.c
> +++ b/drivers/scsi/scsi_transport_iscsi.c
> @@ -3182,11 +3182,14 @@ iscsi_set_host_param(struct iscsi_transport *transport,
> }
>
> /* see similar check in iscsi_if_set_param() */
> - if (strlen(data) > ev->u.set_host_param.len)
> - return -EINVAL;
> + if (strlen(data) > ev->u.set_host_param.len) {
> + err = -EINVAL;
> + goto out;
> + }
>
> err = transport->set_host_param(shost, ev->u.set_host_param.param,
> data, ev->u.set_host_param.len);
> +out:
> scsi_host_put(shost);
> return err;
> }
Reviewed-by: Mike Christie <michael.christie@oracle.com>
next prev parent reply other threads:[~2025-03-25 3:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 9:43 [PATCH] scsi: iscsi: Fix missing scsi_host_put in error path linmq006
2025-03-25 3:03 ` Mike Christie [this message]
2025-04-03 13:47 ` Martin K. Petersen
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=9dfb46b3-3dfe-40ea-9eae-c6a2533ad950@oracle.com \
--to=michael.christie@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=cleech@redhat.com \
--cc=lduncan@suse.com \
--cc=linma@zju.edu.cn \
--cc=linmq006@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=open-iscsi@googlegroups.com \
/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