Fix a bug where reporter->devlink attribute was used after the reporter
was freed.
Fixes: 880ee82f0313 ("devlink: Add health reporter create/destroy
functionality")
Signed-off-by: Eran Ben Elisha <[email protected]>
Reviewed-by: Moshe Shemesh <[email protected]>
---
net/core/devlink.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 379ebd3f9a59..3cb74694de86 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4150,12 +4150,14 @@ EXPORT_SYMBOL_GPL(devlink_health_reporter_create);
void
devlink_health_reporter_destroy(struct devlink_health_reporter *reporter)
{
- mutex_lock(&reporter->devlink->lock);
+ struct devlink *devlink = reporter->devlink;
+
+ mutex_lock(&devlink->lock);
list_del(&reporter->list);
if (reporter->dump_msg_ctx)
devlink_msg_ctx_free(reporter->dump_msg_ctx);
kfree(reporter);
- mutex_unlock(&reporter->devlink->lock);
+ mutex_unlock(&devlink->lock);
}
EXPORT_SYMBOL_GPL(devlink_health_reporter_destroy);
--
2.17.1