|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 1/2] tools/xl: use xrealloc() when parsing llc_colors
The return value of realloc() is not checked when growing the
llc_colors array in parse_config_data(). If the allocation fails, the
loop that follows writes through a NULL pointer and xl crashes.
Use xrealloc() instead, as the rest of xl does. It prints an error and
exits if the allocation fails. The cast is no longer needed.
Fixes: 748bd725fbec ("tools: add support for cache coloring configuration")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Bala Andegue François Lionnel
<balaandeguefrancoislionnel@xxxxxxxxx>
---
Notes:
Build-tested only: an allocation failure is hard to trigger here. The
overflow in patch 2 shows the same NULL pointer write when the count wraps to 0.
tools/xl/xl_parse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 0ccece3e8a18..4aa29f75f3d5 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1555,7 +1555,7 @@ void parse_config_data(const char *config_source,
}
b_info->num_llc_colors += (end - start) + 1;
- b_info->llc_colors = (uint32_t *)realloc(b_info->llc_colors,
+ b_info->llc_colors = xrealloc(b_info->llc_colors,
sizeof(*b_info->llc_colors) * b_info->num_llc_colors);
for (k = start; k <= end; k++)
--
2.39.2
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |