Commit d6f2fd7a authored by Richard Fitzgerald's avatar Richard Fitzgerald Committed by Mark Brown

regmap: kunit: Replace a kmalloc/kfree() pair with KUnit-managed alloc

Replace the kmalloc() and kfree() in raw_read_defaults() with a
kunit_kmalloc() so that KUnit will free it automatically.
Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
Link: https://msgid.link/r/20240408144600.230848-10-rf@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent ce75e06e
...@@ -1360,7 +1360,7 @@ static void raw_read_defaults(struct kunit *test) ...@@ -1360,7 +1360,7 @@ static void raw_read_defaults(struct kunit *test)
return; return;
val_len = sizeof(*rval) * (config.max_register + 1); 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); KUNIT_ASSERT_TRUE(test, rval != NULL);
if (!rval) if (!rval)
return; return;
...@@ -1375,8 +1375,6 @@ static void raw_read_defaults(struct kunit *test) ...@@ -1375,8 +1375,6 @@ static void raw_read_defaults(struct kunit *test)
KUNIT_EXPECT_EQ(test, def, le16_to_cpu((__force __le16)rval[i])); KUNIT_EXPECT_EQ(test, def, le16_to_cpu((__force __le16)rval[i]));
} }
} }
kfree(rval);
} }
static void raw_write_read_single(struct kunit *test) static void raw_write_read_single(struct kunit *test)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment