diff mbox

[01/10] core: Bound check get_chip()

Message ID 1435033560-9180-1-git-send-email-benh@kernel.crashing.org
State Accepted
Headers show

Commit Message

Benjamin Herrenschmidt June 23, 2015, 4:25 a.m. UTC
If get_chip() is called with a centaur chipID, return NULL rather
than access beyond an array boundary

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 core/chip.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/core/chip.c b/core/chip.c
index 7059ec3..00eba41 100644
--- a/core/chip.c
+++ b/core/chip.c
@@ -59,6 +59,8 @@  struct proc_chip *next_chip(struct proc_chip *chip)
 
 struct proc_chip *get_chip(uint32_t chip_id)
 {
+	if (chip_id >= MAX_CHIPS)
+		return NULL;
 	return chips[chip_id];
 }