Re: [PATCH] iscsi-iname: fix iscsi-iname -p access NULL pointer without given IQN prefix

2020-03-25 Thread The Lee-Man
Thank you very much for this bug report and suggested patch, but I cleaned 
up the code and fixed it a little differently.

On Wednesday, March 18, 2020 at 6:46:06 PM UTC-7, wubo40 wrote:
>
> From: Wu Bo  
>
> iscsi-iname -p access NULL pointer without give IQN prefix. 
>
> # iscsi-iname -p 
> Segmentation fault 
>
> Signed-off-by: Wu Bo  
> --- 
>   utils/iscsi-iname.c | 2 +- 
>   1 file changed, 1 insertion(+), 1 deletion(-) 
>
> diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c 
> index da850dc..7df7bb0 100644 
> --- a/utils/iscsi-iname.c 
> +++ b/utils/iscsi-iname.c 
> @@ -69,7 +69,7 @@ main(int argc, char *argv[]) 
>   exit(0); 
>   } else if ( strcmp(prefix, "-p") == 0 ) { 
>   prefix = argv[2]; 
> -if (strnlen(prefix, PREFIX_MAX_LEN + 1) > PREFIX_MAX_LEN) { 
> +if (prefix && (strnlen(prefix, PREFIX_MAX_LEN + 1) > 
> PREFIX_MAX_LEN)) { 
>   printf("Error: Prefix cannot exceed %d " 
>  "characters.\n", PREFIX_MAX_LEN); 
>   exit(1); 
> -- 
> 2.21.0 
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/c6cb350a-f8d2-486b-888c-dfc6e5b69a79%40googlegroups.com.


[PATCH] scsi:libiscsi:Fix an error count for active session

2020-03-25 Thread wubo (T)
From: Wu Bo 

Fix an error count for active session if the total_cmds is invalid 
on the function iscsi_session_setup().
decrement the number of active sessions before the func return.

Signed-off-by: Wu Bo 
---
 drivers/scsi/libiscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 70b99c0..b7158eb 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2771,7 +2771,7 @@ struct iscsi_cls_session *
   "must be a power of 2.\n", total_cmds);
total_cmds = rounddown_pow_of_two(total_cmds);
if (total_cmds < ISCSI_TOTAL_CMDS_MIN)
-   return NULL;
+   goto dec_session_count;
printk(KERN_INFO "iscsi: Rounding can_queue to %d.\n",
   total_cmds);
}
--
1.8.3.1

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/EDBAAA0BBBA2AC4E9C8B6B81DEEE1D6916A28542%40DGGEML525-MBS.china.huawei.com.