From: Andy Shevchenko Date: Wed, 12 Feb 2014 09:02:07 +0000 (-0300) Subject: upstream: [media] lm3560: prevent memory leak in case of pdata absence X-Git-Tag: submit/tizen/20141121.110247~936 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9810e95dd0f95ff943fe4420b2517407075158a8;p=platform%2Fkernel%2Flinux-3.10.git upstream: [media] lm3560: prevent memory leak in case of pdata absence 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 Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- 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;