[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1549660500-26565-1-git-send-email-parav@mellanox.com>
Date: Fri, 8 Feb 2019 15:15:00 -0600
From: Parav Pandit <parav@...lanox.com>
To: netdev@...r.kernel.org, davem@...emloft.net
Cc: parav@...lanox.com
Subject: [PATCHv1 net-next] devlink: Add WARN_ON to catch errors of not cleaning devlink objects
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@...lanox.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(+)
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);
--
1.8.3.1
Powered by blists - more mailing lists