media: atomisp: prevent integer overflow in sh_css_set_black_frame()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 1 Sep 2022 05:20:09 +0000 (07:20 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 24 Sep 2022 08:02:57 +0000 (10:02 +0200)
The "height" and "width" values come from the user so the "height * width"
multiplication can overflow.

Link: https://lore.kernel.org/r/YxBBCRnm3mmvaiuR@kili
Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/pci/sh_css_params.c

index 0e7c38b..67915d7 100644 (file)
@@ -950,8 +950,8 @@ sh_css_set_black_frame(struct ia_css_stream *stream,
                params->fpn_config.data = NULL;
        }
        if (!params->fpn_config.data) {
-               params->fpn_config.data = kvmalloc(height * width *
-                                                  sizeof(short), GFP_KERNEL);
+               params->fpn_config.data = kvmalloc(array3_size(height, width, sizeof(short)),
+                                                  GFP_KERNEL);
                if (!params->fpn_config.data) {
                        IA_CSS_ERROR("out of memory");
                        IA_CSS_LEAVE_ERR_PRIVATE(-ENOMEM);