[PATCHv1,net-next] devlink: Add WARN_ON to catch errors of not cleaning devlink objects
diff mbox series

Message ID 1549660500-26565-1-git-send-email-parav@mellanox.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • [PATCHv1,net-next] devlink: Add WARN_ON to catch errors of not cleaning devlink objects
Related show

Commit Message

Parav Pandit Feb. 8, 2019, 9:15 p.m. UTC
Add WARN_ON to make sure that all sub objects of a devlink device are
cleanedup before freeing the devlink device.
This helps to catch any driver bugs.

Signed-off-by: Parav Pandit <parav@mellanox.com>
---
Changelog:
v0->v1:
 - Added WARN_ON for reporter_list too
 - Change the WARN_ON lists order to follow mirror of its init part.
---
 net/core/devlink.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

David Miller Feb. 11, 2019, 9:41 p.m. UTC | #1
From: Parav Pandit <parav@mellanox.com>
Date: Fri,  8 Feb 2019 15:15:00 -0600

> Add WARN_ON to make sure that all sub objects of a devlink device are
> cleanedup before freeing the devlink device.
> This helps to catch any driver bugs.
> 
> Signed-off-by: Parav Pandit <parav@mellanox.com>

Applied, thanks.

Patch
diff mbox series

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 7fbdba5..ab7ce80 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -5237,6 +5237,14 @@  void devlink_unregister(struct devlink *devlink)
  */
 void devlink_free(struct devlink *devlink)
 {
+	WARN_ON(!list_empty(&devlink->reporter_list));
+	WARN_ON(!list_empty(&devlink->region_list));
+	WARN_ON(!list_empty(&devlink->param_list));
+	WARN_ON(!list_empty(&devlink->resource_list));
+	WARN_ON(!list_empty(&devlink->dpipe_table_list));
+	WARN_ON(!list_empty(&devlink->sb_list));
+	WARN_ON(!list_empty(&devlink->port_list));
+
 	kfree(devlink);
 }
 EXPORT_SYMBOL_GPL(devlink_free);