Skip to content

Commit

Permalink
tile: add null check for kzalloc in tile/kernel/setup.c
Browse files Browse the repository at this point in the history
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: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
  • Loading branch information
Wang Sheng-Hui authored and Chris Metcalf committed Sep 3, 2013
1 parent ce61cdc commit 6d71579
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/tile/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,8 @@ insert_non_bus_resource(void)
{
struct resource *res =
kzalloc(sizeof(struct resource), GFP_ATOMIC);
if (!res)
return NULL;
res->name = "Non-Bus Physical Address Space";
res->start = (1ULL << 32);
res->end = -1LL;
Expand All @@ -1660,6 +1662,8 @@ insert_ram_resource(u64 start_pfn, u64 end_pfn, bool reserved)
{
struct resource *res =
kzalloc(sizeof(struct resource), GFP_ATOMIC);
if (!res)
return NULL;
res->name = reserved ? "Reserved" : "System RAM";
res->start = start_pfn << PAGE_SHIFT;
res->end = (end_pfn << PAGE_SHIFT) - 1;
Expand Down

0 comments on commit 6d71579

Please sign in to comment.