Skip to contentSkip to conversation

MIPS: ath25: check for kzalloc allocation failure

PATCH Applied Colin King 2 participants 2 messages Feb 22, 2018 – Feb 23, 2018

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 MIPS: ath25: check for kzalloc allocation failure

From: Colin Ian King <[email protected]>

Currently there is no null check on a failed allocation of board_data, and hence a null pointer dereference will occurr. Fix this by checking for the out of memory null pointer.

Fixes a7473717483e ("MIPS: ath25: add board configuration detection")
---
 arch/mips/ath25/board.c | 2 ++
 1 file changed, 2 insertions(+)
arch/mips/ath25/board.c +2 -0
index 9ab48ff80c1c..6d11ae581ea7 100644
@@ -135,6 +135,8 @@ int __init ath25_find_config(phys_addr_t base, unsigned long size)
 	}
 
 	board_data = kzalloc(BOARD_CONFIG_BUFSZ, GFP_KERNEL);
+	if (!board_data)
+		goto error;
 	ath25_board.config = (struct ath25_boarddata *)board_data;
 	memcpy_fromio(board_data, bcfg, 0x100);
 	if (broken_boarddata) {
Signature · 1 line
2.15.1
Applied
#1 lore raw
Quoted 8 lines · Colin King

From: Colin Ian King <[email protected]>

Currently there is no null check on a failed allocation of board_data, and hence a null pointer dereference will occurr. Fix this by checking for the out of memory null pointer.

Fixes a7473717483e ("MIPS: ath25: add board configuration detection")

Applied to my fixes branch with 3.19+ stable tag.

Thanks
James