MIPS: ath25: check for kzalloc allocation failure
diff mbox series

Message ID -
State Accepted
Delegated to: James Hogan
Headers show
Series
  • MIPS: ath25: check for kzalloc allocation failure
Related show

Commit Message

Colin King Feb. 22, 2018, 5:50 p.m. UTC
From: Colin Ian King <>

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")
Signed-off-by: Colin Ian King <>
---
 arch/mips/ath25/board.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

James Hogan Feb. 23, 2018, 9:52 a.m. UTC | #1
On Thu, Feb 22, 2018 at 05:50:12PM +0000, Colin King wrote:
> From: Colin Ian King <>
> 
> 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")
> Signed-off-by: Colin Ian King <>

Applied to my fixes branch with 3.19+ stable tag.

Thanks
James

Patch
diff mbox series

diff --git a/arch/mips/ath25/board.c b/arch/mips/ath25/board.c
index 9ab48ff80c1c..6d11ae581ea7 100644
--- a/arch/mips/ath25/board.c
+++ b/arch/mips/ath25/board.c
@@ -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) {