[PATCH] nvmet-fc: skip hostport handling when the LLDD provides no hosthandle
Hannes Reinecke
hare at suse.de
Mon Nov 23 08:32:54 PST 2026
On 11/20/26 9:05 AM, Guixin Liu wrote:
> nvmet_fc_alloc_hostport() returns NULL when the LLDD does not implement
> the hosthandle abstraction, but the association lifetime code assumes
> an association always has a hostport:
>
> - nvmet_fc_xmt_disconnect_assoc() reads assoc->hostport->invalid
> - nvmet_fc_target_assoc_free() drops the hostport reference
> unconditionally
> - nvmet_fc_invalidate_host() compares assoc->hostport->hosthandle
> while scanning the association list
>
> The first and the third dereference were introduced by removing the
> NULL checks on the assumption that an association always has a
> hostport, and the second by inlining nvmet_fc_free_hostport(), which
> dropped the pointer check of the inlined helper. A Create Association
> failure on such a transport then crashes the target.
>
> Restore the checks: skip the Disconnect Association exchange, skip the
> hostport reference drop (there is no reference to balance, the
> association never took one), and skip hosthandle matching in the
> invalidation scan.
>
> Fixes: 50b474e1faff5 ("nvmet-fc: remove null hostport pointer check")
> Fixes: 88517565b5929 ("nvmet-fc: inline nvmet_fc_free_hostport")
> Cc: stable at vger.kernel.org
> Signed-off-by: Guixin Liu <kanie at linux.alibaba.com>
> ---
> drivers/nvme/target/fc.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
Reviewed-by: Hannes Reinecke <hare at kernel.org>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
More information about the Linux-nvme
mailing list