Skip to content

Commit dae29b6

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-ops-test: dynamically allocate struct snd_ctl_elem_value
This structure is really too larget to be allocated on the stack: linux/sound/soc/soc-ops-test.c:520:1: error: the frame size of\ 1304 bytes is larger than 1280 bytes [-Werror=frame-larger-than=] Change the function to dynamically allocate it instead. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://patch.msgid.link/87sek489l8.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 8a5a5ce commit dae29b6

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

sound/soc/soc-ops-test.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,22 +481,27 @@ static void soc_ops_test_access(struct kunit *test)
481481
.private_data = &priv->component,
482482
.private_value = (unsigned long)&param->mc,
483483
};
484-
struct snd_ctl_elem_value result;
485484
unsigned int val;
486485
int ret;
486+
/* it is too large struct. use kzalloc() */
487+
struct snd_ctl_elem_value *result;
488+
489+
result = kzalloc(sizeof(*result), GFP_KERNEL);
490+
if (!result)
491+
return;
487492

488493
ret = regmap_write(priv->component.regmap, 0x0, param->init);
489494
KUNIT_ASSERT_FALSE(test, ret);
490495
ret = regmap_write(priv->component.regmap, 0x1, param->init);
491496
KUNIT_ASSERT_FALSE(test, ret);
492497

493-
result.value.integer.value[0] = param->lctl;
494-
result.value.integer.value[1] = param->rctl;
498+
result->value.integer.value[0] = param->lctl;
499+
result->value.integer.value[1] = param->rctl;
495500

496-
ret = param->put(&kctl, &result);
501+
ret = param->put(&kctl, result);
497502
KUNIT_ASSERT_EQ(test, ret, param->ret);
498503
if (ret < 0)
499-
return;
504+
goto end;
500505

501506
ret = regmap_read(priv->component.regmap, 0x0, &val);
502507
KUNIT_ASSERT_FALSE(test, ret);
@@ -506,17 +511,19 @@ static void soc_ops_test_access(struct kunit *test)
506511
KUNIT_ASSERT_FALSE(test, ret);
507512
KUNIT_EXPECT_EQ(test, val, (param->init & ~param->rmask) | param->rreg);
508513

509-
result.value.integer.value[0] = 0;
510-
result.value.integer.value[1] = 0;
514+
result->value.integer.value[0] = 0;
515+
result->value.integer.value[1] = 0;
511516

512-
ret = param->get(&kctl, &result);
517+
ret = param->get(&kctl, result);
513518
KUNIT_ASSERT_GE(test, ret, 0);
514519

515-
KUNIT_EXPECT_EQ(test, result.value.integer.value[0], param->lctl);
520+
KUNIT_EXPECT_EQ(test, result->value.integer.value[0], param->lctl);
516521
if (param->layout != SOC_OPS_TEST_SINGLE)
517-
KUNIT_EXPECT_EQ(test, result.value.integer.value[1], param->rctl);
522+
KUNIT_EXPECT_EQ(test, result->value.integer.value[1], param->rctl);
518523
else
519-
KUNIT_EXPECT_EQ(test, result.value.integer.value[1], 0);
524+
KUNIT_EXPECT_EQ(test, result->value.integer.value[1], 0);
525+
end:
526+
kfree(result);
520527
}
521528

522529
KUNIT_ARRAY_PARAM(all_info_tests, all_info_test_params, info_test_desc);

0 commit comments

Comments
 (0)