[PATCH net-next v2] lib: objagg: Fix stats imbalance on hinted-parent error path
From: tongzhiwei
Date: Fri Nov 27 2026 - 02:15:27 EST
This issue was discovered by an AI code review agent during static
inspection of the hinted-parent error path. It has not been
triggered or observed at runtime; the analysis was confirmed by
inspecting the code, pairing __objagg_obj_get() with
__objagg_obj_put() on the success path. The fix has not been
runtime-tested. Its only build validation is the automated netdev
build tests run on the v1 submission (identical diff), which passed
with no new warnings. The fix and this commit message were
prepared by the same LLM agent and reviewed by the human submitter.
In objagg_obj_init_with_hints(), the parent is obtained via
__objagg_obj_get() which increments only the refcount without
touching stats. The matching release for internal references is
__objagg_obj_put() (no stats adjustment), as used in the success
path in objagg_obj_parent_unassign().
However, the error cleanup at err_parent_assign calls the public
objagg_obj_put(), which additionally runs objagg_obj_stats_dec(),
decrementing user_count and delta_user_count with no prior
increment. This corrupts the parent stats, leading to
under-reporting and potential user_count underflow.
Use __objagg_obj_put() to match the internal __objagg_obj_get().
Fixes: 9069a3817d82 ("lib: objagg: implement optimization hints assembly and use hints for object creation")
Signed-off-by: tongzhiwei <tongzhiwei@xxxxxxxxxxxxxxxxxxxx>
Reviewed-by: Jiri Pirko <jiri@xxxxxxxxxx>
---
V1 -> V2:
- add the net-next tree designation to the subject
- add the Fixes: tag for the commit that introduced the
hinted-parent error path
- collect the Reviewed-by tag from Jiri Pirko. Thank you for the
review, and sorry for the slow follow-up! The diff is unchanged,
so the tag is carried over as-is
- replace the "NOTE: this commit is worked by llm completely" line
and the "Assisted-by: LLM" trailer with the plain-English
discovery and testing statement above, per the "Bug fixes"
section of Documentation/process/maintainer-netdev.rst
- no code changes
v1: https://lore.kernel.org/r/20261106095621.143-1-tongzhiwei@xxxxxxxxxxxxxxxxxxxx/
lib/objagg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/objagg.c b/lib/objagg.c
index 23c7105a3f9f..6c4144213eb8 100644
--- a/lib/objagg.c
+++ b/lib/objagg.c
@@ -327,7 +327,7 @@ static int objagg_obj_init_with_hints(struct objagg *objagg,
return 0;
err_parent_assign:
- objagg_obj_put(objagg, parent);
+ __objagg_obj_put(objagg, parent);
return err;
}
--
2.43.0