netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv1 net-next] devlink: Add WARN_ON to catch errors of not cleaning devlink objects
@ 2019-02-08 21:15 Parav Pandit
  2019-02-11 21:41 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Parav Pandit @ 2019-02-08 21:15 UTC (permalink / raw)
  To: netdev, davem; +Cc: parav

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(+)

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCHv1 net-next] devlink: Add WARN_ON to catch errors of not cleaning devlink objects
  2019-02-08 21:15 [PATCHv1 net-next] devlink: Add WARN_ON to catch errors of not cleaning devlink objects Parav Pandit
@ 2019-02-11 21:41 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-02-11 21:41 UTC (permalink / raw)
  To: parav; +Cc: netdev

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-11 21:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08 21:15 [PATCHv1 net-next] devlink: Add WARN_ON to catch errors of not cleaning devlink objects Parav Pandit
2019-02-11 21:41 ` David Miller

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).