summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2019-02-08 15:15:00 -0600
committerDavid S. Miller <davem@davemloft.net>2019-02-11 13:21:25 -0800
commitb904aada8033749558e3aaeb574a2200bf0458f0 (patch)
tree5bae307e117c65fe6fbb5a5b34c1afca1ee92181
parentcbd72b485214f085a022b56a3051524577d891fe (diff)
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@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/core/devlink.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c
index e6a015b8ac9b..0de1edb65c24 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -5241,6 +5241,14 @@ EXPORT_SYMBOL_GPL(devlink_unregister);
*/
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);