]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ASoC: soc-ops-test: dynamically allocate struct snd_ctl_elem_value
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Fri, 13 Jun 2025 06:00:20 +0000 (06:00 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 13 Jun 2025 11:23:55 +0000 (12:23 +0100)
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>
sound/soc/soc-ops-test.c

index dc1e482bba6a9335464406e02a0bcd57a74e0f1f..1bafa5626d48b3dc7e5d13440534052c9aabd3e2 100644 (file)
@@ -481,22 +481,27 @@ static void soc_ops_test_access(struct kunit *test)
                .private_data = &priv->component,
                .private_value = (unsigned long)&param->mc,
        };
-       struct snd_ctl_elem_value result;
        unsigned int val;
        int ret;
+       /* it is too large struct. use kzalloc() */
+       struct snd_ctl_elem_value *result;
+
+       result = kzalloc(sizeof(*result), GFP_KERNEL);
+       if (!result)
+               return;
 
        ret = regmap_write(priv->component.regmap, 0x0, param->init);
        KUNIT_ASSERT_FALSE(test, ret);
        ret = regmap_write(priv->component.regmap, 0x1, param->init);
        KUNIT_ASSERT_FALSE(test, ret);
 
-       result.value.integer.value[0] = param->lctl;
-       result.value.integer.value[1] = param->rctl;
+       result->value.integer.value[0] = param->lctl;
+       result->value.integer.value[1] = param->rctl;
 
-       ret = param->put(&kctl, &result);
+       ret = param->put(&kctl, result);
        KUNIT_ASSERT_EQ(test, ret, param->ret);
        if (ret < 0)
-               return;
+               goto end;
 
        ret = regmap_read(priv->component.regmap, 0x0, &val);
        KUNIT_ASSERT_FALSE(test, ret);
@@ -506,17 +511,19 @@ static void soc_ops_test_access(struct kunit *test)
        KUNIT_ASSERT_FALSE(test, ret);
        KUNIT_EXPECT_EQ(test, val, (param->init & ~param->rmask) | param->rreg);
 
-       result.value.integer.value[0] = 0;
-       result.value.integer.value[1] = 0;
+       result->value.integer.value[0] = 0;
+       result->value.integer.value[1] = 0;
 
-       ret = param->get(&kctl, &result);
+       ret = param->get(&kctl, result);
        KUNIT_ASSERT_GE(test, ret, 0);
 
-       KUNIT_EXPECT_EQ(test, result.value.integer.value[0], param->lctl);
+       KUNIT_EXPECT_EQ(test, result->value.integer.value[0], param->lctl);
        if (param->layout != SOC_OPS_TEST_SINGLE)
-               KUNIT_EXPECT_EQ(test, result.value.integer.value[1], param->rctl);
+               KUNIT_EXPECT_EQ(test, result->value.integer.value[1], param->rctl);
        else
-               KUNIT_EXPECT_EQ(test, result.value.integer.value[1], 0);
+               KUNIT_EXPECT_EQ(test, result->value.integer.value[1], 0);
+end:
+       kfree(result);
 }
 
 KUNIT_ARRAY_PARAM(all_info_tests, all_info_test_params, info_test_desc);