[PATCH nvme-7.3 3/4] nvme-fabrics: add helpers for subsystem and host identity options
Christoph Hellwig
hch at lst.de
Wed Sep 2 03:44:56 PDT 2026
On Fri, Aug 21, 2026 at 02:25:28PM +0800, raoxu wrote:
> +static int nvmf_parse_subsysnqn(struct nvmf_ctrl_options *opts, substring_t *args)
> +{
> + char *nqn;
> +
> + nqn = match_strdup(args);
> + if (!nqn)
> + return -ENOMEM;
> +
> + kfree(opts->subsysnqn);
> + opts->subsysnqn = nqn;
> + if (strlen(opts->subsysnqn) >= NVMF_NQN_SIZE) {
> + pr_err("%s needs to be < %d bytes\n",
> + opts->subsysnqn, NVMF_NQN_SIZE);
> + return -EINVAL;
> + }
I think we should only update opts->subsysnqn after the sanity check. The
current code doesn't do that, but we should use the chance to fix that
up as well.
> + nqn = match_strdup(args);
> + if (!nqn)
> + return -ENOMEM;
> +
> + if (strlen(nqn) >= NVMF_NQN_SIZE) {
> + pr_err("%s needs to be < %d bytes\n", nqn, NVMF_NQN_SIZE);
> + kfree(nqn);
> + return -EINVAL;
> + }
> +
> + strscpy(hostnqn, nqn, NVMF_NQN_SIZE);
> + kfree(nqn);
This already gets is right. Also does anyone rememeber why we handled
the host vs subsys NQN so differently?
More information about the Linux-nvme
mailing list