aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-07-26 03:59:51 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-26 20:13:58 -0400
commit4d8729a139782d4facc98b7bd7d87c7d10c128b0 (patch)
treeaeeac81df3dad9808622d2239cd20b7488674e4a /drivers
parenteb80411b54fde031e9a8b368ff7b32c774ecfc5c (diff)
LEDS: memory leak in blinkm_led_common_set()
This can return without freeing the bl_work struct. Also there was no check for allocation failure. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Jan-Simon Möller <jansimon.moeller@gmx.de> Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/leds-blinkm.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/leds/leds-blinkm.c b/drivers/leds/leds-blinkm.c
index 5a9df43e5302..ae6ad6331f23 100644
--- a/drivers/leds/leds-blinkm.c
+++ b/drivers/leds/leds-blinkm.c
@@ -468,8 +468,7 @@ static int blinkm_led_common_set(struct led_classdev *led_cdev,
468 /* led_brightness is 0, 127 or 255 - we just use it here as-is */ 468 /* led_brightness is 0, 127 or 255 - we just use it here as-is */
469 struct blinkm_led *led = cdev_to_blmled(led_cdev); 469 struct blinkm_led *led = cdev_to_blmled(led_cdev);
470 struct blinkm_data *data = i2c_get_clientdata(led->i2c_client); 470 struct blinkm_data *data = i2c_get_clientdata(led->i2c_client);
471 struct blinkm_work *bl_work = kzalloc(sizeof(struct blinkm_work), 471 struct blinkm_work *bl_work;
472 GFP_ATOMIC);
473 472
474 switch (color) { 473 switch (color) {
475 case RED: 474 case RED:
@@ -511,6 +510,10 @@ static int blinkm_led_common_set(struct led_classdev *led_cdev,
511 return -EINVAL; 510 return -EINVAL;
512 } 511 }
513 512
513 bl_work = kzalloc(sizeof(*bl_work), GFP_ATOMIC);
514 if (!bl_work)
515 return -ENOMEM;
516
514 atomic_inc(&led->active); 517 atomic_inc(&led->active);
515 dev_dbg(&led->i2c_client->dev, 518 dev_dbg(&led->i2c_client->dev,
516 "#TO_SCHED# next_red = %d, next_green = %d," 519 "#TO_SCHED# next_red = %d, next_green = %d,"