Commit 6d715790 authored by Wang Sheng-Hui's avatar Wang Sheng-Hui Committed by Chris Metcalf

tile: add null check for kzalloc in tile/kernel/setup.c

Should check the return value of kzalloc first to avoid the null pointer.
Then can dereference the non-null pointer to access the fields of struct
resource.
Signed-off-by: default avatarWang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: default avatarChris Metcalf <cmetcalf@tilera.com>
parent ce61cdc2
...@@ -1643,6 +1643,8 @@ insert_non_bus_resource(void) ...@@ -1643,6 +1643,8 @@ insert_non_bus_resource(void)
{ {
struct resource *res = struct resource *res =
kzalloc(sizeof(struct resource), GFP_ATOMIC); kzalloc(sizeof(struct resource), GFP_ATOMIC);
if (!res)
return NULL;
res->name = "Non-Bus Physical Address Space"; res->name = "Non-Bus Physical Address Space";
res->start = (1ULL << 32); res->start = (1ULL << 32);
res->end = -1LL; res->end = -1LL;
...@@ -1660,6 +1662,8 @@ insert_ram_resource(u64 start_pfn, u64 end_pfn, bool reserved) ...@@ -1660,6 +1662,8 @@ insert_ram_resource(u64 start_pfn, u64 end_pfn, bool reserved)
{ {
struct resource *res = struct resource *res =
kzalloc(sizeof(struct resource), GFP_ATOMIC); kzalloc(sizeof(struct resource), GFP_ATOMIC);
if (!res)
return NULL;
res->name = reserved ? "Reserved" : "System RAM"; res->name = reserved ? "Reserved" : "System RAM";
res->start = start_pfn << PAGE_SHIFT; res->start = start_pfn << PAGE_SHIFT;
res->end = (end_pfn << PAGE_SHIFT) - 1; res->end = (end_pfn << PAGE_SHIFT) - 1;
......
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