[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250910121427.3757718-1-kaushlendra.kumar@intel.com>
Date: Wed, 10 Sep 2025 17:44:27 +0530
From: Kaushlendra Kumar <kaushlendra.kumar@...el.com>
To: dave@...olabs.net,
paulmck@...nel.org,
josh@...htriplett.org,
frederic@...nel.org,
neeraj.upadhyay@...nel.org,
rostedt@...dmis.org
Cc: linux-kernel@...r.kernel.org,
rcu@...r.kernel.org,
markus.elfring@....de,
Kaushlendra Kumar <kaushlendra.kumar@...el.com>
Subject: [PATCH v3] rcu/rcutorture: Improve error handling in rcu_torture_fwd_prog_init()
Restructure error handling in rcu_torture_fwd_prog_init() to provide
cleaner allocation failure paths. The current code checks both
allocations in a single condition, making error handling less
efficient and clear.
The improved approach:
- Check rfp allocation immediately and return early on failure.
- Separately handle fwd_prog_tasks allocation failure with proper
cleanup of allocated resources.
- Remove redundant kfree(fwd_prog_tasks) since it would be NULL on
allocation failure.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@...el.com>
---
Changes in v3:
- Fixed word wrapping to eliminate orphaned words (runts).
- Removed duplicate marker line in changelog.
Changes in v2:
- Fixed word wrapping in commit message to follow kernel guidelines
kernel/rcu/rcutorture.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 807fbf6123a7..6af0d207adba 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -2995,11 +2995,11 @@ static int __init rcu_torture_fwd_prog_init(void)
if (fwd_progress_div <= 0)
fwd_progress_div = 4;
rfp = kcalloc(fwd_progress, sizeof(*rfp), GFP_KERNEL);
+ if (!rfp)
+ return -ENOMEM;
fwd_prog_tasks = kcalloc(fwd_progress, sizeof(*fwd_prog_tasks), GFP_KERNEL);
- if (!rfp || !fwd_prog_tasks) {
+ if (!fwd_prog_tasks) {
kfree(rfp);
- kfree(fwd_prog_tasks);
- fwd_prog_tasks = NULL;
fwd_progress = 0;
return -ENOMEM;
}
--
2.34.1
Powered by blists - more mailing lists