On 12/05/2012 10:52 PM, Nicholas A. Bellinger wrote:
diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index 9602b20..652a608 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -153,22 +153,18 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para
goto out;
}
- param->name = kzalloc(strlen(name) + 1, GFP_KERNEL);
+ param->name = kstrdup(name, GFP_KERNEL);
if (!param->name) {
pr_err("Unable to allocate memory for parameter name.\n");
goto out;
}
- param->value = kzalloc(strlen(value) + 1, GFP_KERNEL);
+ param->value = kstrdup(value, GFP_KERNEL);
if (!param->value) {
pr_err("Unable to allocate memory for parameter value.\n");
goto out;
}
- memcpy(param->name, name, strlen(name));
- param->name[strlen(name)] = '\0';
- memcpy(param->value, value, strlen(value));
- param->value[strlen(value)] = '\0';
Mmmm, I pretty sure that iSCSI still wants the '\0' terminator included
at the end param->[name, value].
So applying this patch, but keeping this around for now.
I'm not sure I get this. The new string _should_ be null terminated.
One difference here is that this code allocates strlen() + 1 bytes of
memory, memcpy(,, strlen()) and adds \0 at end because memcpy did not
so. kstrdup() however uses always strlen() + 1 for kmalloc(), & memcpy()
so it copies the '\0'.
Sebastian
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html