summaryrefslogtreecommitdiff
path: root/net/can/j1939/main.c
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2019-11-08 13:57:14 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2019-11-13 10:42:34 +0100
commit4a15d574e68afffbe8d7265e015cda2ac2a248ec (patch)
tree2918619e9ac79e1707f11de95c3d7d9d88c2d1e2 /net/can/j1939/main.c
parentddeeb7d4822ed06d79fc15e822b70dce3fa77e39 (diff)
can: j1939: warn if resources are still linked on destroy
j1939_session_destroy() and __j1939_priv_release() should be called only if session, ecu or socket are not linked or used by any one else. If at least one of these resources is linked, then the reference counting is broken somewhere. This warning will be triggered before KASAN will do, and will make it easier to debug initial issue. This works on platforms without KASAN support. Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Diffstat (limited to 'net/can/j1939/main.c')
-rw-r--r--net/can/j1939/main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c
index 2afcf27c72c8..137054bff9ec 100644
--- a/net/can/j1939/main.c
+++ b/net/can/j1939/main.c
@@ -152,6 +152,10 @@ static void __j1939_priv_release(struct kref *kref)
netdev_dbg(priv->ndev, "%s: 0x%p\n", __func__, priv);
+ WARN_ON_ONCE(!list_empty(&priv->active_session_list));
+ WARN_ON_ONCE(!list_empty(&priv->ecus));
+ WARN_ON_ONCE(!list_empty(&priv->j1939_socks));
+
dev_put(ndev);
kfree(priv);
}