提交 4d8729a1 编写于 作者: D Dan Carpenter 提交者: Bryan Wu

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: NDan Carpenter <dan.carpenter@oracle.com>
Acked-by: NJan-Simon Möller <jansimon.moeller@gmx.de>
Signed-off-by: NBryan Wu <bryan.wu@canonical.com>
上级 eb80411b
......@@ -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,"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册