media: atomisp: prevent integer overflow in sh_css_set_black_frame()
Subsystems (5)
Media (V4L/DVB) Staging Kernel janitors Intel MID (Mobile Internet Device) platform +1 more subsystems
PATCH 1/1 media: atomisp: prevent integer overflow in sh_css_set_black_frame()
The "height" and "width" values come from the user so the "height * width" multiplication can overflow.
Fixes a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by Dan Carpenter <[email protected]>
--- drivers/staging/media/atomisp/pci/sh_css_params.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/sh_css_params.c +2 -2
@@ -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 );
Signature · 1 line
2.35.1
Hi,
Quoted 5 lines · Dan Carpenter
The "height" and "width" values come from the user so the "height * width" multiplication can overflow.
Fixes a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")Signed-off-by Dan Carpenter <[email protected]>
Thanks, patch looks good to me:
Reviewed-by Hans de Goede <[email protected]>
I'll also add this to my set of pending atomisp2 cleanup patches so that the next time I test the atomisp2 with my local tree this will also get tested.
Regards,
Hans
Quoted 19 lines
--- drivers/staging/media/atomisp/pci/sh_css_params.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/media/atomisp/pci/sh_css_params.c +2
-2@@ -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 );