mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
Merge branch 'devlink-fix-a-couple-parent-ref-leaks'
Cosmin Ratiu says: ==================== devlink: Fix a couple parent ref leaks These two patches fix parent ref leaks on errors. ==================== Link: https://patch.msgid.link/20260616110633.1449432-1-cratiu@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
440a974492
|
|
@ -486,16 +486,19 @@ static int devlink_nl_rate_set(struct devlink_rate *devlink_rate,
|
|||
devlink_rate->tx_weight = weight;
|
||||
}
|
||||
|
||||
nla_parent = attrs[DEVLINK_ATTR_RATE_PARENT_NODE_NAME];
|
||||
if (nla_parent) {
|
||||
err = devlink_nl_rate_parent_node_set(devlink_rate, info,
|
||||
nla_parent);
|
||||
if (attrs[DEVLINK_ATTR_RATE_TC_BWS]) {
|
||||
err = devlink_nl_rate_tc_bw_set(devlink_rate, info);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (attrs[DEVLINK_ATTR_RATE_TC_BWS]) {
|
||||
err = devlink_nl_rate_tc_bw_set(devlink_rate, info);
|
||||
/* Keep parent setting last because it takes a reference. This function
|
||||
* has no rollback, so failing after taking the ref would leak it.
|
||||
*/
|
||||
nla_parent = attrs[DEVLINK_ATTR_RATE_PARENT_NODE_NAME];
|
||||
if (nla_parent) {
|
||||
err = devlink_nl_rate_parent_node_set(devlink_rate, info,
|
||||
nla_parent);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
|
@ -725,11 +728,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 +738,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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user