aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiezhu Yang <[email protected]>2020-01-10 09:30:42 +0800
committerPaul Burton <[email protected]>2020-01-10 14:10:24 -0800
commit72d052e28d1d2363f9107be63ef3a3afdea6143c (patch)
tree4ff25b6864f76dc173d62327ef11ab24c5e9779f
parent23c25c73253075f41466438ed1b42ece9004ba20 (diff)
MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init()
If kzalloc fails, it should return -ENOMEM, otherwise may trigger a NULL pointer dereference. Fixes: 3adeb2566b9b ("MIPS: Loongson: Improve LEFI firmware interface") Signed-off-by: Tiezhu Yang <[email protected]> Signed-off-by: Paul Burton <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Jiaxun Yang <[email protected]> Cc: [email protected] Cc: [email protected]
-rw-r--r--arch/mips/loongson64/platform.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/mips/loongson64/platform.c b/arch/mips/loongson64/platform.c
index 13f3404f0030..9674ae1361a8 100644
--- a/arch/mips/loongson64/platform.c
+++ b/arch/mips/loongson64/platform.c
@@ -27,6 +27,9 @@ static int __init loongson3_platform_init(void)
continue;
pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
+ if (!pdev)
+ return -ENOMEM;
+
pdev->name = loongson_sysconf.sensors[i].name;
pdev->id = loongson_sysconf.sensors[i].id;
pdev->dev.platform_data = &loongson_sysconf.sensors[i];