diff options
author | Wang Sheng-Hui <shhuiw@gmail.com> | 2013-08-21 21:49:42 -0400 |
---|---|---|
committer | Chris Metcalf <cmetcalf@tilera.com> | 2013-09-03 14:53:34 -0400 |
commit | 6d715790ef6b5b903779a14d995ce3d9e680bec0 (patch) | |
tree | 8ff5c867220173ded9e7de932b9a9759855ec5f1 /arch/tile | |
parent | ce61cdc270a5e0dd18057bbf29bd3471abccbda8 (diff) |
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: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile')
-rw-r--r-- | arch/tile/kernel/setup.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c index 128a2d0b8650..c2c42f329c1a 100644 --- a/arch/tile/kernel/setup.c +++ b/arch/tile/kernel/setup.c | |||
@@ -1643,6 +1643,8 @@ insert_non_bus_resource(void) | |||
1643 | { | 1643 | { |
1644 | struct resource *res = | 1644 | struct resource *res = |
1645 | kzalloc(sizeof(struct resource), GFP_ATOMIC); | 1645 | kzalloc(sizeof(struct resource), GFP_ATOMIC); |
1646 | if (!res) | ||
1647 | return NULL; | ||
1646 | res->name = "Non-Bus Physical Address Space"; | 1648 | res->name = "Non-Bus Physical Address Space"; |
1647 | res->start = (1ULL << 32); | 1649 | res->start = (1ULL << 32); |
1648 | res->end = -1LL; | 1650 | res->end = -1LL; |
@@ -1660,6 +1662,8 @@ insert_ram_resource(u64 start_pfn, u64 end_pfn, bool reserved) | |||
1660 | { | 1662 | { |
1661 | struct resource *res = | 1663 | struct resource *res = |
1662 | kzalloc(sizeof(struct resource), GFP_ATOMIC); | 1664 | kzalloc(sizeof(struct resource), GFP_ATOMIC); |
1665 | if (!res) | ||
1666 | return NULL; | ||
1663 | res->name = reserved ? "Reserved" : "System RAM"; | 1667 | res->name = reserved ? "Reserved" : "System RAM"; |
1664 | res->start = start_pfn << PAGE_SHIFT; | 1668 | res->start = start_pfn << PAGE_SHIFT; |
1665 | res->end = (end_pfn << PAGE_SHIFT) - 1; | 1669 | res->end = (end_pfn << PAGE_SHIFT) - 1; |