drm/pl111: Use 64-bit arithmetic instead of 32-bit
Subsystems (3)
PATCH v2 1/1 drm/pl111: Use 64-bit arithmetic instead of 32-bit
Add suffix ULL to constant 1000 in order to give the compiler complete information about the proper arithmetic to use.
Notice that such constant is used in a context that expects an expression of type u64 (64 bits, unsigned) and the following expression is currently being evaluated using 32-bit arithmetic:
mode->clock * 1000
Addresses-Coverity-ID: 1466139 ("Unintentional integer overflow")
---
Changes in v2:
- Use suffix ULL instead of UL.
drivers/gpu/drm/pl111/pl111_display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/pl111/pl111_display.c +1 -1
@@ -63,7 +63,7 @@ pl111_mode_valid(struct drm_crtc *crtc,* We use the pixelclock to also account for interlaced modes, the * resulting bandwidth is in bytes per second. */ - bw = mode->clock *1000 ;/* In Hz */ + bw = mode->clock *1000ULL ;/* In Hz */ bw = bw * mode->hdisplay * mode->vdisplay * cpp; bw =div_u64 (bw, mode->htotal * mode->vtotal);
Signature · 1 line
2.7.4
Quoted 11 lines · Gustavo A. R. Silva
Add suffix ULL to constant 1000 in order to give the compiler complete information about the proper arithmetic to use.
Notice that such constant is used in a context that expects an expression of type u64 (64 bits, unsigned) and the following expression is currently being evaluated using 32-bit arithmetic:
mode->clock* 1000Addresses-Coverity-ID: 1466139 ("Unintentional integer overflow")
Signed-off-by Gustavo A. R. Silva <[email protected]>
This is silly. The clock won't be over 4ghz -- we haven't seen anything over 1024x768 on this hardware as far as I know. The u64 is for the multiplication by width/height below.
I've still applied the patch to shut up the tool.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Eric,
Quoted 9 lines · Eric Anholt
Quoted 7 lines · Gustavo A. R. Silva
Add suffix ULL to constant 1000 in order to give the compiler complete information about the proper arithmetic to use.
Notice that such constant is used in a context that expects an expression of type u64 (64 bits, unsigned) and the following expression is currently being evaluated using 32-bit arithmetic:
Quoted 9 lines
Quoted 4 lines
mode->clock* 1000Addresses-Coverity-ID: 1466139 ("Unintentional integer overflow")
Signed-off-by Gustavo A. R. Silva <[email protected]>This is silly. The clock won't be over 4ghz -- we haven't seen anything over 1024x768 on this hardware as far as I know. The u64 is for the multiplication by width/height below.
Yep. I understand. That's why I didn't use the word *fix* anywhere in the changelog.
Quoted 2 lines
I've still applied the patch to shut up the tool.
Thanks
--
Gustavo