diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-07-26 15:59:51 +0800 |
---|---|---|
committer | Bryan Wu <bryan.wu@canonical.com> | 2012-07-27 08:13:58 +0800 |
commit | 4d8729a139782d4facc98b7bd7d87c7d10c128b0 (patch) | |
tree | aeeac81df3dad9808622d2239cd20b7488674e4a /drivers/leds | |
parent | eb80411b54fde031e9a8b368ff7b32c774ecfc5c (diff) | |
download | op-kernel-dev-4d8729a139782d4facc98b7bd7d87c7d10c128b0.zip op-kernel-dev-4d8729a139782d4facc98b7bd7d87c7d10c128b0.tar.gz |
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/leds')
-rw-r--r-- | drivers/leds/leds-blinkm.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/leds/leds-blinkm.c b/drivers/leds/leds-blinkm.c index 5a9df43..ae6ad63 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, /* led_brightness is 0, 127 or 255 - we just use it here as-is */ struct blinkm_led *led = cdev_to_blmled(led_cdev); struct blinkm_data *data = i2c_get_clientdata(led->i2c_client); - struct blinkm_work *bl_work = kzalloc(sizeof(struct blinkm_work), - GFP_ATOMIC); + struct blinkm_work *bl_work; switch (color) { case RED: @@ -511,6 +510,10 @@ static int blinkm_led_common_set(struct led_classdev *led_cdev, return -EINVAL; } + bl_work = kzalloc(sizeof(*bl_work), GFP_ATOMIC); + if (!bl_work) + return -ENOMEM; + atomic_inc(&led->active); dev_dbg(&led->i2c_client->dev, "#TO_SCHED# next_red = %d, next_green = %d," |