diff options
author | Ma Ke <make_ruc2021@163.com> | 2024-12-17 10:55:38 +0300 |
---|---|---|
committer | Leon Romanovsky <leon@kernel.org> | 2024-12-19 14:50:36 +0300 |
commit | a3cbf68c69611188cd304229e346bffdabfd4277 (patch) | |
tree | 442ee9b2bef7b7a16740d05cc61c3145a5ada347 | |
parent | db03b70969aab4ef111a3369cfd90ea4da3a6aa0 (diff) | |
download | linux-a3cbf68c69611188cd304229e346bffdabfd4277.tar.xz |
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: c8e4c2397655 ("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>
-rw-r--r-- | drivers/infiniband/ulp/srp/ib_srp.c | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 2916e77f589b..7289ae0b83ac 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3978,7 +3978,6 @@ static struct srp_host *srp_add_port(struct srp_device *device, u32 port) return host; put_host: - device_del(&host->dev); put_device(&host->dev); return NULL; } |