Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Kuninori Morimoto and committed by
Mark Brown
dae29b67 8a5a5cec

+18 -11
+18 -11
sound/soc/soc-ops-test.c
··· 481 481 .private_data = &priv->component, 482 482 .private_value = (unsigned long)&param->mc, 483 483 }; 484 - struct snd_ctl_elem_value result; 485 484 unsigned int val; 486 485 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; 487 492 488 493 ret = regmap_write(priv->component.regmap, 0x0, param->init); 489 494 KUNIT_ASSERT_FALSE(test, ret); 490 495 ret = regmap_write(priv->component.regmap, 0x1, param->init); 491 496 KUNIT_ASSERT_FALSE(test, ret); 492 497 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; 495 500 496 - ret = param->put(&kctl, &result); 501 + ret = param->put(&kctl, result); 497 502 KUNIT_ASSERT_EQ(test, ret, param->ret); 498 503 if (ret < 0) 499 - return; 504 + goto end; 500 505 501 506 ret = regmap_read(priv->component.regmap, 0x0, &val); 502 507 KUNIT_ASSERT_FALSE(test, ret); ··· 511 506 KUNIT_ASSERT_FALSE(test, ret); 512 507 KUNIT_EXPECT_EQ(test, val, (param->init & ~param->rmask) | param->rreg); 513 508 514 - result.value.integer.value[0] = 0; 515 - result.value.integer.value[1] = 0; 509 + result->value.integer.value[0] = 0; 510 + result->value.integer.value[1] = 0; 516 511 517 - ret = param->get(&kctl, &result); 512 + ret = param->get(&kctl, result); 518 513 KUNIT_ASSERT_GE(test, ret, 0); 519 514 520 - KUNIT_EXPECT_EQ(test, result.value.integer.value[0], param->lctl); 515 + KUNIT_EXPECT_EQ(test, result->value.integer.value[0], param->lctl); 521 516 if (param->layout != SOC_OPS_TEST_SINGLE) 522 - KUNIT_EXPECT_EQ(test, result.value.integer.value[1], param->rctl); 517 + KUNIT_EXPECT_EQ(test, result->value.integer.value[1], param->rctl); 523 518 else 524 - KUNIT_EXPECT_EQ(test, result.value.integer.value[1], 0); 519 + KUNIT_EXPECT_EQ(test, result->value.integer.value[1], 0); 520 + end: 521 + kfree(result); 525 522 } 526 523 527 524 KUNIT_ARRAY_PARAM(all_info_tests, all_info_test_params, info_test_desc);