nvmf: Use not malloc'ed but fixed size string for host NQN
Maximum size of NQN is already defined to be SPDK_NVMF_NQN_MAX_LEN, and hence use fixed size string whose size is SPDK_NVMF_NQN_MAX_LEN + 1 for spdk_nvmf_vhost::nqn. This change will reduce the potential malloc failure. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I2b9c7cc21200b3e88b5485ebfdcd5040bc6e3589 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459742 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Seth Howell <seth.howell5141@gmail.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
dae8e89253
commit
12d6dce2aa
@ -90,7 +90,7 @@ struct spdk_nvmf_tgt {
|
||||
};
|
||||
|
||||
struct spdk_nvmf_host {
|
||||
char *nqn;
|
||||
char nqn[SPDK_NVMF_NQN_MAX_LEN + 1];
|
||||
TAILQ_ENTRY(spdk_nvmf_host) link;
|
||||
};
|
||||
|
||||
|
@ -308,7 +308,6 @@ static void
|
||||
_spdk_nvmf_subsystem_remove_host(struct spdk_nvmf_subsystem *subsystem, struct spdk_nvmf_host *host)
|
||||
{
|
||||
TAILQ_REMOVE(&subsystem->hosts, host, link);
|
||||
free(host->nqn);
|
||||
free(host);
|
||||
}
|
||||
|
||||
@ -648,11 +647,8 @@ spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem, const char *
|
||||
if (!host) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
host->nqn = strdup(hostnqn);
|
||||
if (!host->nqn) {
|
||||
free(host);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
snprintf(host->nqn, sizeof(host->nqn), "%s", hostnqn);
|
||||
|
||||
TAILQ_INSERT_HEAD(&subsystem->hosts, host, link);
|
||||
subsystem->tgt->discovery_genctr++;
|
||||
|
Loading…
Reference in New Issue
Block a user