From: Gen Zhang <blackgod016574@gmail.com>
To: nsekhar@ti.com, bgolaszewski@baylibre.com, linux@armlinux.org.uk
Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH] board-dm644x-evm: fix 2 missing-check bugs in evm_led_setup()
Date: Fri, 27 Dec 2019 10:39:21 +0800 [thread overview]
Message-ID: <20191227023921.GA21233@zhanggen-UX430UQ> (raw)
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;
}
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2019-12-27 2:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-27 2:39 Gen Zhang [this message]
2019-12-27 16:01 ` [PATCH] board-dm644x-evm: fix 2 missing-check bugs in evm_led_setup() Russell King - ARM Linux admin
2019-12-28 13:19 ` Gen Zhang
2019-12-28 13:48 ` Russell King - ARM Linux admin
2019-12-28 15:40 ` Gen Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191227023921.GA21233@zhanggen-UX430UQ \
--to=blackgod016574@gmail.com \
--cc=bgolaszewski@baylibre.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nsekhar@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox