Skip to content

Commit 5105f80

Browse files
committed
devlink: fix xa_alloc_cyclic() error handling
JIRA: https://issues.redhat.com/browse/RHEL-75600 Upstream commit(s): commit f3b97b7 Author: Michal Swiatkowski <[email protected]> Date: Wed Mar 12 10:52:49 2025 +0100 devlink: fix xa_alloc_cyclic() error handling In case of returning 1 from xa_alloc_cyclic() (wrapping) ERR_PTR(1) will be returned, which will cause IS_ERR() to be false. Which can lead to dereference not allocated pointer (rel). Fix it by checking if err is lower than zero. This wasn't found in real usecase, only noticed. Credit to Pierre. Fixes: c137743 ("devlink: introduce object and nested devlink relationship infra") Signed-off-by: Michal Swiatkowski <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Petr Oros <[email protected]>
1 parent 39f9c2e commit 5105f80

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/devlink/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static struct devlink_rel *devlink_rel_alloc(void)
117117

118118
err = xa_alloc_cyclic(&devlink_rels, &rel->index, rel,
119119
xa_limit_32b, &next, GFP_KERNEL);
120-
if (err) {
120+
if (err < 0) {
121121
kfree(rel);
122122
return ERR_PTR(err);
123123
}

0 commit comments

Comments
 (0)