Skip to content

Commit a3cbf68

Browse files
Ma Kerleon
authored andcommitted
RDMA/srp: Fix error handling in srp_add_port
As comment of device_add() says, if device_add() succeeds, you should call device_del() when you want to get rid of it. If device_add() has not succeeded, use only put_device() to drop the reference count. Add a put_device() call before returning from the function to decrement reference count for cleanup. Found by code review. Fixes: c8e4c23 ("RDMA/srp: Rework the srp_add_port() error path") Signed-off-by: Ma Ke <make_ruc2021@163.com> Link: https://patch.msgid.link/20241217075538.2909996-1-make_ruc2021@163.com Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent db03b70 commit a3cbf68

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

drivers/infiniband/ulp/srp/ib_srp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3978,7 +3978,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u32 port)
39783978
return host;
39793979

39803980
put_host:
3981-
device_del(&host->dev);
39823981
put_device(&host->dev);
39833982
return NULL;
39843983
}

0 commit comments

Comments
 (0)