* [PATCH] scsi: iscsi: Fix missing scsi_host_put in error path
@ 2025-03-18 9:43 linmq006
2025-03-25 3:03 ` Mike Christie
2025-04-03 13:47 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: linmq006 @ 2025-03-18 9:43 UTC (permalink / raw)
To: Lee Duncan, Chris Leech, Mike Christie, James E.J. Bottomley,
Martin K. Petersen, Lin Ma, open-iscsi, linux-scsi, linux-kernel
Cc: linmq006
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;
}
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: iscsi: Fix missing scsi_host_put in error path
2025-03-18 9:43 [PATCH] scsi: iscsi: Fix missing scsi_host_put in error path linmq006
@ 2025-03-25 3:03 ` Mike Christie
2025-04-03 13:47 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Mike Christie @ 2025-03-25 3:03 UTC (permalink / raw)
To: linmq006, Lee Duncan, Chris Leech, James E.J. Bottomley,
Martin K. Petersen, Lin Ma, open-iscsi, linux-scsi, linux-kernel
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>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: iscsi: Fix missing scsi_host_put in error path
2025-03-18 9:43 [PATCH] scsi: iscsi: Fix missing scsi_host_put in error path linmq006
2025-03-25 3:03 ` Mike Christie
@ 2025-04-03 13:47 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2025-04-03 13:47 UTC (permalink / raw)
To: linmq006
Cc: Lee Duncan, Chris Leech, Mike Christie, James E.J. Bottomley,
Martin K. Petersen, Lin Ma, open-iscsi, linux-scsi, linux-kernel
> 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.
Applied to 6.15/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-03 13:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 9:43 [PATCH] scsi: iscsi: Fix missing scsi_host_put in error path linmq006
2025-03-25 3:03 ` Mike Christie
2025-04-03 13:47 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox