public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: ath25: check for kzalloc allocation failure
@ 2018-02-22 17:50 Colin King
  2018-02-23  9:52 ` James Hogan
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2018-02-22 17:50 UTC (permalink / raw)
  To: Ralf Baechle, James Hogan, linux-mips; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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 <colin.king@canonical.com>
---
 arch/mips/ath25/board.c | 2 ++
 1 file changed, 2 insertions(+)

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) {
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MIPS: ath25: check for kzalloc allocation failure
  2018-02-22 17:50 [PATCH] MIPS: ath25: check for kzalloc allocation failure Colin King
@ 2018-02-23  9:52 ` James Hogan
  0 siblings, 0 replies; 2+ messages in thread
From: James Hogan @ 2018-02-23  9:52 UTC (permalink / raw)
  To: Colin King; +Cc: Ralf Baechle, linux-mips, kernel-janitors, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 512 bytes --]

On Thu, Feb 22, 2018 at 05:50:12PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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 <colin.king@canonical.com>

Applied to my fixes branch with 3.19+ stable tag.

Thanks
James

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-23  9:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-22 17:50 [PATCH] MIPS: ath25: check for kzalloc allocation failure Colin King
2018-02-23  9:52 ` James Hogan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox