From 8b9528a6d9a901b9f933231505fef5630e80ce5a Mon Sep 17 00:00:00 2001
From: Mario Limonciello <mario.limonciello@dell.com>
Date: Thu, 9 Nov 2017 11:49:09 -0600
Subject: [PATCH] platform/x86: dell-wmi-descriptor: check if memory was allocated
Mime-version: 1.0
Content-type: text/plain; charset=UTF-8
Content-transfer-encoding: 8bit
Git-commit: 8b9528a6d9a901b9f933231505fef5630e80ce5a
Patch-mainline: v4.15-rc1
References: FATE#325842
devm_kzalloc will return NULL pointer if no memory was allocated.
This should be checked. This problem also existed when the driver
was dell-wmi.c.
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
Acked-by: Takashi Iwai <tiwai@suse.de>
---
drivers/platform/x86/dell-wmi-descriptor.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/drivers/platform/x86/dell-wmi-descriptor.c
+++ b/drivers/platform/x86/dell-wmi-descriptor.c
@@ -121,6 +121,11 @@ static int dell_wmi_descriptor_probe(str
priv = devm_kzalloc(&wdev->dev, sizeof(struct descriptor_priv),
GFP_KERNEL);
+ if (!priv) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
priv->interface_version = buffer[2];
priv->size = buffer[3];
ret = 0;