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

David Binderman dcb314 at hotmail.com
Mon Jan 4 09:51:09 PST 2016


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 

 		 	   		  


More information about the linux-arm-kernel mailing list