mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 03:27:30 -04:00
devlink: Fix parent ref leak in devl_rate_node_create()
In the original commit the function bails out on kstrdup failure,
forgetting to decrement the refcnt of the parent.
Fix that by moving the parent refcnt setting after kstrdup.
Fixes: caba177d7f ("devlink: Enable creation of the devlink-rate nodes from the driver")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260616110633.1449432-2-cratiu@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
8cdcf3d2ca
commit
ba45106342
@@ -725,11 +725,6 @@ devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name,
|
||||
if (!rate_node)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
if (parent) {
|
||||
rate_node->parent = parent;
|
||||
refcount_inc(&rate_node->parent->refcnt);
|
||||
}
|
||||
|
||||
rate_node->type = DEVLINK_RATE_TYPE_NODE;
|
||||
rate_node->devlink = devlink;
|
||||
rate_node->priv = priv;
|
||||
@@ -740,6 +735,11 @@ devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name,
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
rate_node->parent = parent;
|
||||
refcount_inc(&rate_node->parent->refcnt);
|
||||
}
|
||||
|
||||
refcount_set(&rate_node->refcnt, 1);
|
||||
list_add(&rate_node->list, &devlink->rate_list);
|
||||
devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW);
|
||||
|
||||
Reference in New Issue
Block a user