[media] lm3560: prevent memory leak in case of pdata absence
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 12 Feb 2014 09:02:07 +0000 (06:02 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 11 Mar 2014 12:56:39 +0000 (09:56 -0300)
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.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/i2c/lm3560.c

index 93e52270c9cce381f1632a3cbff001e40c5c5e0c..c23de593c17d5572ff2123403ad6e4e006d21e55 100644 (file)
@@ -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;