mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <patches@opensource.cirrus.com>,
	"Richard Fitzgerald" <rf@opensource.cirrus.com>
Subject: [PATCH 09/11] regmap: kunit: Replace a kmalloc/kfree() pair with KUnit-managed alloc
Date: Mon, 8 Apr 2024 15:45:58 +0100	[thread overview]
Message-ID: <20240408144600.230848-10-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20240408144600.230848-1-rf@opensource.cirrus.com>

Replace the kmalloc() and kfree() in raw_read_defaults() with a
kunit_kmalloc() so that KUnit will free it automatically.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 drivers/base/regmap/regmap-kunit.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regmap-kunit.c b/drivers/base/regmap/regmap-kunit.c
index e21028cbddc3..4c29d2db4d20 100644
--- a/drivers/base/regmap/regmap-kunit.c
+++ b/drivers/base/regmap/regmap-kunit.c
@@ -1360,7 +1360,7 @@ static void raw_read_defaults(struct kunit *test)
 		return;
 
 	val_len = sizeof(*rval) * (config.max_register + 1);
-	rval = kmalloc(val_len, GFP_KERNEL);
+	rval = kunit_kmalloc(test, val_len, GFP_KERNEL);
 	KUNIT_ASSERT_TRUE(test, rval != NULL);
 	if (!rval)
 		return;
@@ -1375,8 +1375,6 @@ static void raw_read_defaults(struct kunit *test)
 			KUNIT_EXPECT_EQ(test, def, le16_to_cpu((__force __le16)rval[i]));
 		}
 	}
-
-	kfree(rval);
 }
 
 static void raw_write_read_single(struct kunit *test)
-- 
2.39.2


  parent reply	other threads:[~2024-04-08 14:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 14:45 [PATCH 00/11] regmap: kunit: Add some test cases and a few small improvements Richard Fitzgerald
2024-04-08 14:45 ` [PATCH 01/11] regmap: kunit: Fix warnings of implicit casts to __le16 and __be16 Richard Fitzgerald
2024-04-08 14:45 ` [PATCH 02/11] regmap: kunit: Create a struct device for the regmap Richard Fitzgerald
2024-04-08 14:45 ` [PATCH 03/11] regmap: kunit: Introduce struct for test case parameters Richard Fitzgerald
2024-04-08 14:45 ` [PATCH 04/11] regmap: kunit: Run sparse cache tests at non-zero register addresses Richard Fitzgerald
2024-05-16 19:53   ` Guenter Roeck
2024-05-17 11:28     ` Mark Brown
2024-05-17 15:19       ` Guenter Roeck
2024-05-17 11:58     ` Richard Fitzgerald
2024-05-17 13:10     ` Richard Fitzgerald
2024-05-17 15:44     ` Richard Fitzgerald
2024-05-17 15:57       ` Guenter Roeck
2024-04-08 14:45 ` [PATCH 05/11] regmap: kunit: Run non-sparse " Richard Fitzgerald
2024-04-08 14:45 ` [PATCH 06/11] regmap: kunit: Add more cache-drop tests Richard Fitzgerald
2024-04-08 14:45 ` [PATCH 07/11] regmap: kunit: Add more cache-sync tests Richard Fitzgerald
2024-04-08 14:45 ` [PATCH 08/11] regmap: kunit: Use a KUnit action to call regmap_exit() Richard Fitzgerald
2024-04-08 14:45 ` Richard Fitzgerald [this message]
2024-04-08 14:45 ` [PATCH 10/11] regmap: kunit: Add cache-drop test with multiple cache blocks Richard Fitzgerald
2024-04-08 14:46 ` [PATCH 11/11] regmap: kunit: Add test cases for regmap_read_bypassed() Richard Fitzgerald
2024-04-09 23:34 ` [PATCH 00/11] regmap: kunit: Add some test cases and a few small improvements Mark Brown

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=20240408144600.230848-10-rf@opensource.cirrus.com \
    --to=rf@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®