All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Luis Chamberlain <mcgrof@kernel.org>,
	Shuah Khan <shuah@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jessica Yu <jeyu@kernel.org>
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Markus Elfring <Markus.Elfring@web.de>,
	Xuefeng Li <lixuefeng@loongson.cn>
Subject: [PATCH v2 4/4] test_kmod: Avoid potential double free in trigger_config_run_type()
Date: Mon, 20 Apr 2020 19:23:02 +0800	[thread overview]
Message-ID: <1587381782-31047-4-git-send-email-yangtiezhu@loongson.cn> (raw)
In-Reply-To: <1587381782-31047-1-git-send-email-yangtiezhu@loongson.cn>

Reset the member “test_fs” of the test configuration after a call
of the function “kfree_const” to a null pointer so that a double
memory release will not be performed.

Fixes: d9c6a72d6fa2 ("kmod: add test driver to stress test the module loader")
Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---

v2:
  - update the commit message suggested by Markus Elfring
  - add the Fixes tag

 lib/test_kmod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index e651c37..eab5277 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -745,7 +745,7 @@ static int trigger_config_run_type(struct kmod_test_device *test_dev,
 		break;
 	case TEST_KMOD_FS_TYPE:
 		kfree_const(config->test_fs);
-		config->test_driver = NULL;
+		config->test_fs = NULL;
 		copied = config_copy_test_fs(config, test_str,
 					     strlen(test_str));
 		break;
-- 
2.1.0


  parent reply	other threads:[~2020-04-20 11:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20 11:22 [PATCH v2 1/4] selftests: kmod: Use variable NAME in kmod_test_0001() Tiezhu Yang
2020-04-20 11:23 ` [PATCH v2 2/4] kmod: Remove redundant "be an" in the comment Tiezhu Yang
2020-04-20 11:23 ` [PATCH v2 3/4] kmod: Return directly if module name is empty in request_module() Tiezhu Yang
2020-04-20 11:23 ` Tiezhu Yang [this message]
2020-04-20 11:30 ` [PATCH v2 1/4] selftests: kmod: Use variable NAME in kmod_test_0001() Markus Elfring
2020-04-20 11:40   ` Tiezhu Yang
2020-04-20 12:12     ` [v2 1/4] selftests: kmod: Subsequent patch series with cover letters? Markus Elfring

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=1587381782-31047-4-git-send-email-yangtiezhu@loongson.cn \
    --to=yangtiezhu@loongson.cn \
    --cc=Markus.Elfring@web.de \
    --cc=akpm@linux-foundation.org \
    --cc=jeyu@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=mcgrof@kernel.org \
    --cc=shuah@kernel.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.