leds: Use devm_kzalloc in leds-pwm.c file
devm_kzalloc() makes cleanup simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 3ed92f3..f2e44c7 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -57,7 +57,8 @@
if (!pdata)
return -EBUSY;
- leds_data = kzalloc(sizeof(struct led_pwm_data) * pdata->num_leds,
+ leds_data = devm_kzalloc(&pdev->dev,
+ sizeof(struct led_pwm_data) * pdata->num_leds,
GFP_KERNEL);
if (!leds_data)
return -ENOMEM;
@@ -103,8 +104,6 @@
}
}
- kfree(leds_data);
-
return ret;
}
@@ -121,8 +120,6 @@
pwm_free(leds_data[i].pwm);
}
- kfree(leds_data);
-
return 0;
}