Skip to content

Commit d6f2fd7

Browse files
rfvirgilbroonie
authored andcommitted
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: Richard Fitzgerald <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ce75e06 commit d6f2fd7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/base/regmap/regmap-kunit.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ static void raw_read_defaults(struct kunit *test)
13601360
return;
13611361

13621362
val_len = sizeof(*rval) * (config.max_register + 1);
1363-
rval = kmalloc(val_len, GFP_KERNEL);
1363+
rval = kunit_kmalloc(test, val_len, GFP_KERNEL);
13641364
KUNIT_ASSERT_TRUE(test, rval != NULL);
13651365
if (!rval)
13661366
return;
@@ -1375,8 +1375,6 @@ static void raw_read_defaults(struct kunit *test)
13751375
KUNIT_EXPECT_EQ(test, def, le16_to_cpu((__force __le16)rval[i]));
13761376
}
13771377
}
1378-
1379-
kfree(rval);
13801378
}
13811379

13821380
static void raw_write_read_single(struct kunit *test)

0 commit comments

Comments
 (0)