mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wang Yufen <wangyufen@huawei.com>
To: <jgg@ziepe.ca>, <leon@kernel.org>, <markzhang@nvidia.com>,
	<haakon.bugge@oracle.com>, <mbloch@nvidia.com>
Cc: <sean.hefty@intel.com>, <rolandd@cisco.com>,
	<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Wang Yufen <wangyufen@huawei.com>
Subject: [PATCH] infiniband: cma: fix the dev refcnt leak
Date: Tue, 22 Nov 2022 14:47:53 +0800	[thread overview]
Message-ID: <1669099673-12213-1-git-send-email-wangyufen@huawei.com> (raw)

Syzbot report the following issue:
  infiniband syj1: RDMA CMA: cma_listen_on_dev, error -98
  unregister_netdevice: waiting for vlan0 to become free. Usage count = 2

The causes are as follows:

rdma_listen()
  rdma_bind_addr()
    cma_acquire_dev_by_src_ip()
      cma_attach_to_dev()
        _cma_attach_to_dev()
          cma_dev_get()

  cma_check_port()
  <--The return value is -98, goto err

err:
<-- The error handling here is missing the operation of cma_release_dev.

To fix, add cma_release_dev to error handing.

Fixes: e51060f08a61 ("IB: IP address based RDMA connection manager")
Reported-by: syzbot+5e70d01ee8985ae62a3b@syzkaller.appspotmail.com
Signed-off-by: Wang Yufen <wangyufen@huawei.com>
---
 drivers/infiniband/core/cma.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 26d1772..3a50a8e 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -4049,6 +4049,9 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
 	return 0;
 err:
 	id_priv->backlog = 0;
+	if (id_priv->cma_dev)
+		cma_release_dev(id_priv);
+
 	/*
 	 * All the failure paths that lead here will not allow the req_handler's
 	 * to have run.
-- 
1.8.3.1


             reply	other threads:[~2022-11-22  6:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-22  6:47 Wang Yufen [this message]
2022-11-22 14:03 ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1669099673-12213-1-git-send-email-wangyufen@huawei.com \
    --to=wangyufen@huawei.com \
    --cc=haakon.bugge@oracle.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markzhang@nvidia.com \
    --cc=mbloch@nvidia.com \
    --cc=rolandd@cisco.com \
    --cc=sean.hefty@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®