rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rcu/rcutorture: Improve error handling in rcu_torture_fwd_prog_init()
@ 2025-09-10  8:36 Kaushlendra Kumar
  2025-09-10  9:07 ` Markus Elfring
  0 siblings, 1 reply; 3+ messages in thread
From: Kaushlendra Kumar @ 2025-09-10  8:36 UTC (permalink / raw)
  To: dave, paulmck, josh, frederic, neeraj.upadhyay, rostedt
  Cc: linux-kernel, rcu, Kaushlendra Kumar

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
- Remove redundant kfree(fwd_prog_tasks) since it would be NULL on
  failure

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] rcu/rcutorture: Improve error handling in rcu_torture_fwd_prog_init()
  2025-09-10  8:36 [PATCH] rcu/rcutorture: Improve error handling in rcu_torture_fwd_prog_init() Kaushlendra Kumar
@ 2025-09-10  9:07 ` Markus Elfring
  2025-09-10  9:32   ` Kumar, Kaushlendra
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2025-09-10  9:07 UTC (permalink / raw)
  To: Kaushlendra Kumar, rcu
  Cc: LKML, Davidlohr Bueso, Frederic Weisbecker, Josh Triplett,
	Neeraj Upadhyay, Paul E. McKenney, Steven Rostedt

> 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.
…

I suggest to refine the word wrapping for such a change description.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n658

Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] rcu/rcutorture: Improve error handling in rcu_torture_fwd_prog_init()
  2025-09-10  9:07 ` Markus Elfring
@ 2025-09-10  9:32   ` Kumar, Kaushlendra
  0 siblings, 0 replies; 3+ messages in thread
From: Kumar, Kaushlendra @ 2025-09-10  9:32 UTC (permalink / raw)
  To: Markus Elfring, rcu@vger.kernel.org
  Cc: LKML, Davidlohr Bueso, Frederic Weisbecker, Josh Triplett,
	Neeraj Upadhyay, Paul E. McKenney, Steven Rostedt



Hi Markus,

On [Date], Markus Elfring <Markus.Elfring@web.de> wrote:
> > 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.
> …
> 
> I suggest to refine the word wrapping for such a change description.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n658

Thank you for the feedback on the word wrapping!
I have sent a v2 patch with properly wrapped lines as suggested


Best regards,
Kaushlendra Kumar

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-10  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-10  8:36 [PATCH] rcu/rcutorture: Improve error handling in rcu_torture_fwd_prog_init() Kaushlendra Kumar
2025-09-10  9:07 ` Markus Elfring
2025-09-10  9:32   ` Kumar, Kaushlendra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).