Skip to contentSkip to conversation

jz4740-hwmon: check kmalloc() result

PATCH RESEND In review Axel Lin 2 participants 2 messages Aug 2, 2010 Hardware monitoring

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH RESEND 1/1 jz4740-hwmon: check kmalloc() result

Quoted 1 line

From 16482398f86ac6cc3b08b10352efd01b56d67473 Mon Sep 17 00:00:00 2001

From: Axel Lin <[email protected]>
Date: Mon, 2 Aug 2010 09:02:26 +0800
Subject: [PATCH] jz4740-hwmon: check kmalloc() result

If kmalloc() fails exit with -ENOMEM.

---
This patch is against linux-next.
This resend separates the fix for jz4740-hwmon and jz474-adc in 2 patches.

 drivers/hwmon/jz4740-hwmon.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/hwmon/jz4740-hwmon.c +4 -0
index 72a4335..1c8b3d9 100644
@@ -107,6 +107,10 @@ static int __devinit jz4740_hwmon_probe(struct platform_device *pdev)
 	struct jz4740_hwmon *hwmon;
 
 	hwmon = kmalloc(sizeof(*hwmon), GFP_KERNEL);
+	if (!hwmon) {
+		dev_err(&pdev->dev, "Failed to allocate driver structure\n");
+		return -ENOMEM;
+	}
 
 	hwmon->cell = pdev->dev.platform_data;
 
Signature · 1 line
1.5.4.3
#1 lore raw
Quoted 5 lines · Axel Lin

From: Axel Lin <[email protected]>
Date: Mon, 2 Aug 2010 09:02:26 +0800
Subject: [PATCH] jz4740-hwmon: check kmalloc() result

If kmalloc() fails exit with -ENOMEM.

Thanks, folded into the existing patch.

Ralf