lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed,  4 Jul 2012 13:10:14 +0800
From:	Bryan Wu <bryan.wu@...onical.com>
To:	linux-leds@...r.kernel.org, rpurdie@...ys.net,
	linux-kernel@...r.kernel.org
Subject: [PATCH 22/25] leds: convert GPIO LED trigger driver to devm_kzalloc() and cleanup error exit path

Cc: Felipe Balbi <me@...ipebalbi.com>
Signed-off-by: Bryan Wu <bryan.wu@...onical.com>
---
 drivers/leds/ledtrig-gpio.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c
index ba215dc..39bd8e4 100644
--- a/drivers/leds/ledtrig-gpio.c
+++ b/drivers/leds/ledtrig-gpio.c
@@ -181,13 +181,13 @@ static void gpio_trig_activate(struct led_classdev *led)
 	struct gpio_trig_data *gpio_data;
 	int ret;
 
-	gpio_data = kzalloc(sizeof(*gpio_data), GFP_KERNEL);
+	gpio_data = devm_kzalloc(led->dev, sizeof(*gpio_data), GFP_KERNEL);
 	if (!gpio_data)
 		return;
 
 	ret = device_create_file(led->dev, &dev_attr_gpio);
 	if (ret)
-		goto err_gpio;
+		return;
 
 	ret = device_create_file(led->dev, &dev_attr_inverted);
 	if (ret)
@@ -209,9 +209,6 @@ err_brightness:
 
 err_inverted:
 	device_remove_file(led->dev, &dev_attr_gpio);
-
-err_gpio:
-	kfree(gpio_data);
 }
 
 static void gpio_trig_deactivate(struct led_classdev *led)
@@ -225,7 +222,6 @@ static void gpio_trig_deactivate(struct led_classdev *led)
 		flush_work(&gpio_data->work);
 		if (gpio_data->gpio != 0)
 			free_irq(gpio_to_irq(gpio_data->gpio), led);
-		kfree(gpio_data);
 		led->activated = false;
 	}
 }
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ