public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RDMA: don't ignore client->add() failures
@ 2023-03-28 10:52 Tetsuo Handa
  2023-03-28 11:24 ` Jason Gunthorpe
  0 siblings, 1 reply; 14+ messages in thread
From: Tetsuo Handa @ 2023-03-28 10:52 UTC (permalink / raw)
  To: Bernard Metzler, Jason Gunthorpe, Leon Romanovsky, Ursula Braun
  Cc: OFED mailing list

syzbot is reporting refcount leak when client->add() from
add_client_context() fails, for commit 11a0ae4c4bff ("RDMA: Allow
ib_client's to fail when add() is called") for unknown reason ignores
error from client->add(). We need to return an error in order to indicate
that client could not be added, otherwise the caller will get confused.

Reported-by: syzbot <syzbot+5e70d01ee8985ae62a3b@syzkaller.appspotmail.com>
Link: https://syzkaller.appspot.com/bug?extid=5e70d01ee8985ae62a3b
Fixes: 11a0ae4c4bff ("RDMA: Allow ib_client's to fail when add() is called")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 drivers/infiniband/core/device.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index a666847bd714..c72f810ceae1 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -718,17 +718,17 @@ static int add_client_context(struct ib_device *device,
 		goto out;
 	downgrade_write(&device->client_data_rwsem);
 	if (client->add) {
-		if (client->add(device)) {
+		ret = client->add(device);
+		if (ret) {
 			/*
-			 * If a client fails to add then the error code is
-			 * ignored, but we won't call any more ops on this
-			 * client.
+			 * If a client fails to add, we won't call any more
+			 * ops on this client.
 			 */
 			xa_erase(&device->client_data, client->client_id);
 			up_read(&device->client_data_rwsem);
 			ib_device_put(device);
 			ib_client_put(client);
-			return 0;
+			return ret;
 		}
 	}
 
-- 
2.18.4

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

end of thread, other threads:[~2023-04-01 18:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-28 10:52 [PATCH] RDMA: don't ignore client->add() failures Tetsuo Handa
2023-03-28 11:24 ` Jason Gunthorpe
2023-03-28 11:33   ` Tetsuo Handa
2023-03-28 11:34     ` Jason Gunthorpe
2023-03-28 14:59       ` Tetsuo Handa
2023-03-28 16:18         ` Jason Gunthorpe
2023-03-28 22:17           ` Tetsuo Handa
2023-03-29 15:44             ` Jason Gunthorpe
2023-03-29 23:51               ` Tetsuo Handa
2023-03-30 23:39                 ` Jason Gunthorpe
2023-03-31 16:19                   ` Tetsuo Handa
2023-03-31 16:23                     ` Jason Gunthorpe
2023-04-01  7:30                       ` Tetsuo Handa
2023-04-01 18:30                         ` Leon Romanovsky

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