mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] RDMA/srp: Fix error handling in srp_add_port
@ 2024-12-17 10:46 Ma Ke
  2024-12-17 16:14 ` Bart Van Assche
  0 siblings, 1 reply; 2+ messages in thread
From: Ma Ke @ 2024-12-17 10:46 UTC (permalink / raw)
  To: bvanassche, jgg, leon; +Cc: linux-rdma, linux-kernel, Ma Ke, stable

Once device_add() failed, we should call only put_device() to
decrement reference count for cleanup. We should not call device_del()
before put_device().

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'.

Found by code review.
Cc: stable@vger.kernel.org
Fixes: c8e4c2397655 ("RDMA/srp: Rework the srp_add_port() error path")
Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
Changes in v2:
- modified the bug description as suggestions.
---
 drivers/infiniband/ulp/srp/ib_srp.c | 1 -
 1 file changed, 1 deletion(-)

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;
 }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] RDMA/srp: Fix error handling in srp_add_port
  2024-12-17 10:46 [PATCH v2] RDMA/srp: Fix error handling in srp_add_port Ma Ke
@ 2024-12-17 16:14 ` Bart Van Assche
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Van Assche @ 2024-12-17 16:14 UTC (permalink / raw)
  To: Ma Ke, jgg, leon; +Cc: linux-rdma, linux-kernel, stable

On 12/17/24 2:46 AM, Ma Ke wrote:
> Once device_add() failed, we should call only put_device() to
> decrement reference count for cleanup. We should not call device_del()
> before put_device().
> 
> 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'.
> 
> Found by code review.
> Cc: stable@vger.kernel.org
> Fixes: c8e4c2397655 ("RDMA/srp: Rework the srp_add_port() error path")
> Signed-off-by: Ma Ke <make_ruc2021@163.com>

Patch descriptions should be in the imperative mood.

A blank line should separate the description and the tags.

Otherwise this patch looks good to me. Hence:

Signed-off-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-17 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-17 10:46 [PATCH v2] RDMA/srp: Fix error handling in srp_add_port Ma Ke
2024-12-17 16:14 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®