2024-01-30 09:53:09

by Daniel Wagner

[permalink] [raw]
Subject: [PATCH v4 06/12] 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 <[email protected]>
Signed-off-by: Daniel Wagner <[email protected]>
---
drivers/nvme/target/fc.c | 2 --
1 file changed, 2 deletions(-)

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;
--
2.43.0



2024-01-31 06:27:53

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH v4 06/12] nvmet-fc: hold reference on hostport match

On Tue, Jan 30, 2024 at 10:49:32AM +0100, Daniel Wagner wrote:
> 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 <[email protected]>
> Signed-off-by: Daniel Wagner <[email protected]>

Looks good:

Reviewed-by: Christoph Hellwig <[email protected]>