doit_reply_value() directly returns on get counter failure, which results in stale sk_buff and genetlink header that aren't cleaned up. Fix it and while at it, consolidate error handling using goto. Fixes: c36218dc49f5 ("drm/ras: Introduce the DRM RAS infrastructure over generic netlink") Signed-off-by: Raag Jadav --- v2: Use goto (Riana) --- drivers/gpu/drm/drm_ras.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_ras.c b/drivers/gpu/drm/drm_ras.c index d6eab29a1394..467a169026fc 100644 --- a/drivers/gpu/drm/drm_ras.c +++ b/drivers/gpu/drm/drm_ras.c @@ -201,25 +201,28 @@ static int doit_reply_value(struct genl_info *info, u32 node_id, hdr = genlmsg_iput(msg, info); if (!hdr) { - nlmsg_free(msg); - return -EMSGSIZE; + ret = -EMSGSIZE; + goto free_msg; } ret = get_node_error_counter(node_id, error_id, &error_name, &value); if (ret) - return ret; + goto cancel_msg; ret = msg_reply_value(msg, error_id, error_name, value); - if (ret) { - genlmsg_cancel(msg, hdr); - nlmsg_free(msg); - return ret; - } + if (ret) + goto cancel_msg; genlmsg_end(msg, hdr); return genlmsg_reply(msg, info); + +cancel_msg: + genlmsg_cancel(msg, hdr); +free_msg: + nlmsg_free(msg); + return ret; } /** -- 2.43.0