From cd0d009183b0a0ce2e048c90d9f94ab06f297b1d Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Fri, 10 Jul 2015 15:24:35 +0530 Subject: hdata/memory: Introduce zalloc() return check In add_size_to_ram_area(), Introduce check for memory allocation failure, before using it. Fixes Coverity defect#97840. Signed-off-by: Kamalesh Babulal Signed-off-by: Stewart Smith --- hdata/memory.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'hdata') diff --git a/hdata/memory.c b/hdata/memory.c index 6bc86959..58acd632 100644 --- a/hdata/memory.c +++ b/hdata/memory.c @@ -244,6 +244,10 @@ static void add_size_to_ram_area(struct dt_node *ram_node, return; str = zalloc(kwsz + 1); + if (!str){ + prerror("Allocation failed\n"); + return; + } memcpy(str, kw, kwsz); dt_add_property_string(ram_node, "size", str); free(str); -- cgit v1.2.1