lkml.org 
[lkml]   [2019]   [Dec]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] board-dm644x-evm: fix 2 missing-check bugs in evm_led_setup()
In evm_led_setup(), the allocation result of platform_device_alloc() and 
platform_device_add_data() should be checked.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
---
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 9d87d4e..9cd2785 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -352,15 +352,20 @@ evm_led_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)
* device unregistration ...
*/
evm_led_dev = platform_device_alloc("leds-gpio", 0);
- platform_device_add_data(evm_led_dev,
+ if (!evm_led_dev)
+ return -ENOMEM;
+ status = platform_device_add_data(evm_led_dev,
&evm_led_data, sizeof evm_led_data);
+ if (status)
+ goto err;

evm_led_dev->dev.parent = &client->dev;
status = platform_device_add(evm_led_dev);
- if (status < 0) {
- platform_device_put(evm_led_dev);
- evm_led_dev = NULL;
- }
+ if (status)
+ goto err;
+err:
+ platform_device_put(evm_led_dev);
+ evm_led_dev = NULL;
return status;
}

\
 
 \ /
  Last update: 2019-12-27 03:39    [W:0.102 / U:8.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site