If we have no pdata defined and driver fails to register we leak memory.
Converting to devm_kzalloc prevents this to happen.

Signed-off-by: Andy Shevchenko <andriy.shevche...@linux.intel.com>
---
 drivers/media/i2c/lm3560.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index 93e5227..c23de59 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -416,8 +416,7 @@ static int lm3560_probe(struct i2c_client *client,
 
        /* if there is no platform data, use chip default value */
        if (pdata == NULL) {
-               pdata =
-                   kzalloc(sizeof(struct lm3560_platform_data), GFP_KERNEL);
+               pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
                if (pdata == NULL)
                        return -ENODEV;
                pdata->peak = LM3560_PEAK_3600mA;
-- 
1.9.0.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to