linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Alex Vainman <alexv@mellanox.com>,
	Artemy Kovalyov <artemyko@mellanox.com>,
	Daniel Jurgens <danielj@mellanox.com>,
	Eli Cohen <eli@mellanox.com>, Haggai Eran <haggaie@mellanox.com>,
	Mark Zhang <markz@mellanox.com>, Moni Shoua <monis@mellanox.com>,
	Parav Pandit <parav@mellanox.com>,
	Sagi Grimberg <sagig@mellanox.com>,
	Yishai Hadas <yishaih@mellanox.com>
Subject: [PATCH rdma-rc 01/10] RDMA/core: Annotate destroy of mutex to ensure that it is released as unlocked
Date: Tue, 23 Jul 2019 09:57:24 +0300	[thread overview]
Message-ID: <20190723065733.4899-2-leon@kernel.org> (raw)
In-Reply-To: <20190723065733.4899-1-leon@kernel.org>

From: Parav Pandit <parav@mellanox.com>

While compiled with CONFIG_DEBUG_MUTEXES, the kernel ensures that mutex
is not held during destroy.
Hence add mutex_destroy() for mutexes used in RDMA modules.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 drivers/infiniband/core/cache.c        | 1 +
 drivers/infiniband/core/cma_configfs.c | 8 +++++++-
 drivers/infiniband/core/device.c       | 3 +++
 drivers/infiniband/core/user_mad.c     | 2 +-
 drivers/infiniband/core/uverbs_main.c  | 4 ++++
 drivers/infiniband/core/verbs.c        | 1 +
 6 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 18e476b3ced0..00fb3eacda19 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -810,6 +810,7 @@ static void release_gid_table(struct ib_device *device,
 	if (leak)
 		return;

+	mutex_destroy(&table->lock);
 	kfree(table->data_vec);
 	kfree(table);
 }
diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c
index 3ec2c415bb70..8b0b5ae22e4c 100644
--- a/drivers/infiniband/core/cma_configfs.c
+++ b/drivers/infiniband/core/cma_configfs.c
@@ -342,12 +342,18 @@ static struct configfs_subsystem cma_subsys = {

 int __init cma_configfs_init(void)
 {
+	int ret;
+
 	config_group_init(&cma_subsys.su_group);
 	mutex_init(&cma_subsys.su_mutex);
-	return configfs_register_subsystem(&cma_subsys);
+	ret = configfs_register_subsystem(&cma_subsys);
+	if (ret)
+		mutex_destroy(&cma_subsys.su_mutex);
+	return ret;
 }

 void __exit cma_configfs_exit(void)
 {
 	configfs_unregister_subsystem(&cma_subsys);
+	mutex_destroy(&cma_subsys.su_mutex);
 }
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index c56993e5e5ea..c3576c7d2e8f 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -497,6 +497,9 @@ static void ib_device_release(struct device *device)
 			  rcu_head);
 	}

+	mutex_destroy(&dev->unregistration_lock);
+	mutex_destroy(&dev->compat_devs_mutex);
+
 	xa_destroy(&dev->compat_devs);
 	xa_destroy(&dev->client_data);
 	kfree_rcu(dev, rcu_head);
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 9f8a48016b41..e0512aef033c 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1038,7 +1038,7 @@ static int ib_umad_close(struct inode *inode, struct file *filp)
 				ib_unregister_mad_agent(file->agent[i]);

 	mutex_unlock(&file->port->file_mutex);
-
+	mutex_destroy(&file->mutex);
 	kfree(file);
 	return 0;
 }
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 11c13c1381cf..02b57240176c 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -120,6 +120,8 @@ static void ib_uverbs_release_dev(struct device *device)

 	uverbs_destroy_api(dev->uapi);
 	cleanup_srcu_struct(&dev->disassociate_srcu);
+	mutex_destroy(&dev->lists_mutex);
+	mutex_destroy(&dev->xrcd_tree_mutex);
 	kfree(dev);
 }

@@ -212,6 +214,8 @@ void ib_uverbs_release_file(struct kref *ref)

 	if (file->disassociate_page)
 		__free_pages(file->disassociate_page, 0);
+	mutex_destroy(&file->umap_lock);
+	mutex_destroy(&file->ucontext_lock);
 	kfree(file);
 }

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 92349bf37589..f974b6854224 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -2259,6 +2259,7 @@ int ib_dealloc_xrcd(struct ib_xrcd *xrcd, struct ib_udata *udata)
 		if (ret)
 			return ret;
 	}
+	mutex_destroy(&xrcd->tgt_qp_mutex);

 	return xrcd->device->ops.dealloc_xrcd(xrcd, udata);
 }
--
2.20.1


  reply	other threads:[~2019-07-23  6:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23  6:57 [PATCH rdma-rc 00/10] Collection of fixes for 5.3 Leon Romanovsky
2019-07-23  6:57 ` Leon Romanovsky [this message]
2019-07-23  6:57 ` [PATCH rdma-rc 02/10] IB/mlx5: Fix unreg_umr to ignore the mkey state Leon Romanovsky
2019-07-23  6:57 ` [PATCH rdma-rc 03/10] IB/mlx5: Use direct mkey destroy command upon UMR unreg failure Leon Romanovsky
2019-07-23  6:57 ` [PATCH rdma-rc 04/10] IB/mlx5: Fix unreg_umr to set a device PD Leon Romanovsky
2019-07-23  6:57 ` [PATCH rdma-rc 05/10] IB/mlx5: Fix clean_mr() to work in the expected order Leon Romanovsky
2019-07-23  6:57 ` [PATCH rdma-rc 06/10] IB/mlx5: Fix RSS Toeplitz function to be specification aligned Leon Romanovsky
2019-07-23  6:57 ` [PATCH rdma-rc 07/10] IB/mlx5: Prevent concurrent MR updates during invalidation Leon Romanovsky
2019-07-23  6:57 ` [PATCH rdma-rc 08/10] IB/mlx5: Avoid unnecessary typecast Leon Romanovsky
2019-07-23  6:57 ` [PATCH rdma-rc 09/10] IB/core: Fix querying total rdma stats Leon Romanovsky
2019-07-23  6:57 ` [PATCH rdma-rc 10/10] IB/counters: Initialize port counter and annotate mutex_destroy Leon Romanovsky
2019-07-25 14:32   ` Jason Gunthorpe
2019-07-25 15:13 ` [PATCH rdma-rc 00/10] Collection of fixes for 5.3 Jason Gunthorpe
2019-07-25 16:05   ` Parav Pandit

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=20190723065733.4899-2-leon@kernel.org \
    --to=leon@kernel.org \
    --cc=alexv@mellanox.com \
    --cc=artemyko@mellanox.com \
    --cc=danielj@mellanox.com \
    --cc=dledford@redhat.com \
    --cc=eli@mellanox.com \
    --cc=haggaie@mellanox.com \
    --cc=jgg@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markz@mellanox.com \
    --cc=monis@mellanox.com \
    --cc=parav@mellanox.com \
    --cc=sagig@mellanox.com \
    --cc=yishaih@mellanox.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;
as well as URLs for NNTP newsgroup(s).