media: smiapp: check memory allocation failure
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Thu, 24 Aug 2017 05:58:39 +0000 (01:58 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Sun, 27 Aug 2017 00:15:13 +0000 (20:15 -0400)
Check memory allocation failure and return -ENOMEM in such a case.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/i2c/smiapp/smiapp-core.c

index aff55e1dffe73b348f8aa77c74863f33968b1a75..700f433261d01b7700756cde33c2ca8b05af3e59 100644 (file)
@@ -841,6 +841,8 @@ static int smiapp_get_mbus_formats(struct smiapp_sensor *sensor)
                &client->dev,
                compressed_max_bpp - sensor->compressed_min_bpp + 1,
                sizeof(*sensor->valid_link_freqs), GFP_KERNEL);
+       if (!sensor->valid_link_freqs)
+               return -ENOMEM;
 
        for (i = 0; i < ARRAY_SIZE(smiapp_csi_data_formats); i++) {
                const struct smiapp_csi_data_format *f =