linux-4.4-rc8/drivers/media/platform/s5p-tv/mixer_video.c:270: possible int/long mixup ?

From: David Binderman <hidden>
Date: 2016-01-04 17:51:09

Hello there,

[linux-4.4-rc8/drivers/media/platform/s5p-tv/mixer_video.c:270]: (style) int result is returned as long value. If the return value is long to avoid loss of information, then you have loss of information.

Source code is

unsigned long mxr_get_plane_size(const struct mxr_block *blk,
??? unsigned int width, unsigned int height)
{
??? unsigned int bl_width = divup(width, blk->width);
??? unsigned int bl_height = divup(height, blk->height);

??? return bl_width * bl_height * blk->size;
}

Suggest new code

unsigned long mxr_get_plane_size(const struct mxr_block *blk,
??? unsigned int width, unsigned int height)
{
??? unsigned int bl_width = divup(width, blk->width);
??? unsigned int bl_height = divup(height, blk->height);

??? return bl_width * bl_height * (unsigned long) blk->size;
}

Addition of the cast causes both multiplies to be in unsigned long
type, not unsigned int, thus preserving values.


Regards

David Binderman 

 		 	   		  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help