From: Daniel Wagner Date: Wed, 31 Jan 2024 08:51:06 +0000 (+0100) Subject: nvmet-fc: hold reference on hostport match X-Git-Tag: block-6.8-2024-02-01~1^2~10 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=ca121a0f7515591dba0eb5532bfa7ace4dc153ce;p=linux-block.git nvmet-fc: hold reference on hostport match The hostport data structure is shared between the association, this why we keep track of the users via a refcount. So we should not decrement the refcount on a match and free the hostport several times. Reported by KASAN. Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Signed-off-by: Keith Busch --- diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index b44b99525c44..205a12b1e841 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1068,8 +1068,6 @@ nvmet_fc_alloc_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle) /* new allocation not needed */ kfree(newhost); newhost = match; - /* no new allocation - release reference */ - nvmet_fc_tgtport_put(tgtport); } else { newhost->tgtport = tgtport; newhost->hosthandle = hosthandle;