All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jinjie Ruan <ruanjinjie@huawei.com>
To: <brendan.higgins@linux.dev>, <davidgow@google.com>,
	<skhan@linuxfoundation.org>, <dlatypov@google.com>,
	<rmoar@google.com>, <janusz.krzysztofik@linux.intel.com>,
	<linux-kselftest@vger.kernel.org>, <kunit-dev@googlegroups.com>,
	Ruan Jinjie <ruanjinjie@huawei.com>
Subject: [PATCH v2 2/4] kunit: Fix the wrong kfree of copy for kunit_filter_suites()
Date: Thu, 21 Sep 2023 09:40:06 +0800	[thread overview]
Message-ID: <20230921014008.3887257-3-ruanjinjie@huawei.com> (raw)
In-Reply-To: <20230921014008.3887257-1-ruanjinjie@huawei.com>

If the outer layer for loop is iterated more than once and it fails not
in the first iteration, the copy pointer has been moved. So it should free
the original copy's backup copy_start.

Fixes: abbf73816b6f ("kunit: fix possible memory leak in kunit_filter_suites()")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Rae Moar <rmoar@google.com>
---
v2:
- Add Reviewed-by.
---
 lib/kunit/executor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c
index a037a46fae5e..9358ed2df839 100644
--- a/lib/kunit/executor.c
+++ b/lib/kunit/executor.c
@@ -243,7 +243,7 @@ kunit_filter_suites(const struct kunit_suite_set *suite_set,
 
 free_copy:
 	if (*err)
-		kfree(copy);
+		kfree(copy_start);
 
 	return filtered;
 }
-- 
2.34.1


  parent reply	other threads:[~2023-09-21  1:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21  1:40 [PATCH v2 0/4] kunit: Fix some bugs in kunit Jinjie Ruan
2023-09-21  1:40 ` [PATCH v2 1/4] kunit: Fix missed memory release in kunit_free_suite_set() Jinjie Ruan
2023-09-22  7:34   ` David Gow
2023-09-21  1:40 ` Jinjie Ruan [this message]
2023-09-22  7:34   ` [PATCH v2 2/4] kunit: Fix the wrong kfree of copy for kunit_filter_suites() David Gow
2023-09-21  1:40 ` [PATCH v2 3/4] kunit: Fix possible memory leak in kunit_filter_suites() Jinjie Ruan
2023-09-22  7:34   ` David Gow
2023-09-21  1:40 ` [PATCH v2 4/4] kunit: test: Fix the possible memory leak in executor_test Jinjie Ruan
2023-09-21 19:50   ` Rae Moar
2023-09-22  6:37     ` Ruan Jinjie
2023-09-22  7:34   ` David Gow
2023-09-22  7:45     ` Ruan Jinjie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230921014008.3887257-3-ruanjinjie@huawei.com \
    --to=ruanjinjie@huawei.com \
    --cc=brendan.higgins@linux.dev \
    --cc=davidgow@google.com \
    --cc=dlatypov@google.com \
    --cc=janusz.krzysztofik@linux.intel.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=rmoar@google.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.