Commit 1b80ac64 authored by Kees Cook's avatar Kees Cook Committed by Michael Ellerman

powerpc/msi: Remove VLA usage

In the quest to remove all stack VLA usage from the kernel[1], this
switches from an unchanging variable to a constant expression to
eliminate the VLA generation.

[1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.comSigned-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 00c376fd
...@@ -225,22 +225,23 @@ static void __init test_of_node(void) ...@@ -225,22 +225,23 @@ static void __init test_of_node(void)
struct device_node of_node; struct device_node of_node;
struct property prop; struct property prop;
struct msi_bitmap bmp; struct msi_bitmap bmp;
int size = 256; #define SIZE_EXPECTED 256
DECLARE_BITMAP(expected, size); DECLARE_BITMAP(expected, SIZE_EXPECTED);
/* There should really be a struct device_node allocator */ /* There should really be a struct device_node allocator */
memset(&of_node, 0, sizeof(of_node)); memset(&of_node, 0, sizeof(of_node));
of_node_init(&of_node); of_node_init(&of_node);
of_node.full_name = node_name; of_node.full_name = node_name;
WARN_ON(msi_bitmap_alloc(&bmp, size, &of_node)); WARN_ON(msi_bitmap_alloc(&bmp, SIZE_EXPECTED, &of_node));
/* No msi-available-ranges, so expect > 0 */ /* No msi-available-ranges, so expect > 0 */
WARN_ON(msi_bitmap_reserve_dt_hwirqs(&bmp) <= 0); WARN_ON(msi_bitmap_reserve_dt_hwirqs(&bmp) <= 0);
/* Should all still be free */ /* Should all still be free */
WARN_ON(bitmap_find_free_region(bmp.bitmap, size, get_count_order(size))); WARN_ON(bitmap_find_free_region(bmp.bitmap, SIZE_EXPECTED,
bitmap_release_region(bmp.bitmap, 0, get_count_order(size)); get_count_order(SIZE_EXPECTED)));
bitmap_release_region(bmp.bitmap, 0, get_count_order(SIZE_EXPECTED));
/* Now create a fake msi-available-ranges property */ /* Now create a fake msi-available-ranges property */
...@@ -256,8 +257,8 @@ static void __init test_of_node(void) ...@@ -256,8 +257,8 @@ static void __init test_of_node(void)
WARN_ON(msi_bitmap_reserve_dt_hwirqs(&bmp)); WARN_ON(msi_bitmap_reserve_dt_hwirqs(&bmp));
/* Check we got the expected result */ /* Check we got the expected result */
WARN_ON(bitmap_parselist(expected_str, expected, size)); WARN_ON(bitmap_parselist(expected_str, expected, SIZE_EXPECTED));
WARN_ON(!bitmap_equal(expected, bmp.bitmap, size)); WARN_ON(!bitmap_equal(expected, bmp.bitmap, SIZE_EXPECTED));
msi_bitmap_free(&bmp); msi_bitmap_free(&bmp);
kfree(bmp.bitmap); kfree(bmp.bitmap);
......
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