From: Colin Ian King Date: Thu, 22 Feb 2018 17:50:12 +0000 (+0000) Subject: MIPS: ath25: Check for kzalloc allocation failure X-Git-Tag: v4.1.51~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35c2a6d45dde1dc8ec418bf4a467b059500237f1;p=thirdparty%2Fkernel%2Fstable.git MIPS: ath25: Check for kzalloc allocation failure [ Upstream commit 1b22b4b28fd5fbc51855219e3238b3ab81da8466 ] 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 Cc: Ralf Baechle Cc: linux-mips@linux-mips.org Cc: # 3.19+ Patchwork: https://patchwork.linux-mips.org/patch/18657/ Signed-off-by: James Hogan Signed-off-by: Sasha Levin --- diff --git a/arch/mips/ath25/board.c b/arch/mips/ath25/board.c index b8bb78282d6a6..7df779f2cb631 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) {