mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 22:21:40 +00:00
drm/i915: use check_add_overflow() and drop local variants
Prefer common check_add_overflow() from overflow.h over the locally rolled versions of it. While check_add_overflow() does require a variable to assign to, unlike add_overflows_t(), it's still better than having multiple versions around. Cc: Kees Cook <keescook@chromium.org> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240405202625.2525671-1-jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
This commit is contained in:
parent
860cefce5e
commit
fdac5a10b4
@ -1106,7 +1106,7 @@ static int intel_fb_offset_to_xy(int *x, int *y,
|
|||||||
{
|
{
|
||||||
struct drm_i915_private *i915 = to_i915(fb->dev);
|
struct drm_i915_private *i915 = to_i915(fb->dev);
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
u32 alignment;
|
u32 alignment, unused;
|
||||||
|
|
||||||
if (DISPLAY_VER(i915) >= 12 &&
|
if (DISPLAY_VER(i915) >= 12 &&
|
||||||
!intel_fb_needs_pot_stride_remap(to_intel_framebuffer(fb)) &&
|
!intel_fb_needs_pot_stride_remap(to_intel_framebuffer(fb)) &&
|
||||||
@ -1128,8 +1128,8 @@ static int intel_fb_offset_to_xy(int *x, int *y,
|
|||||||
height = ALIGN(height, intel_tile_height(fb, color_plane));
|
height = ALIGN(height, intel_tile_height(fb, color_plane));
|
||||||
|
|
||||||
/* Catch potential overflows early */
|
/* Catch potential overflows early */
|
||||||
if (add_overflows_t(u32, mul_u32_u32(height, fb->pitches[color_plane]),
|
if (check_add_overflow(mul_u32_u32(height, fb->pitches[color_plane]),
|
||||||
fb->offsets[color_plane])) {
|
fb->offsets[color_plane], &unused)) {
|
||||||
drm_dbg_kms(&i915->drm,
|
drm_dbg_kms(&i915->drm,
|
||||||
"Bad offset 0x%08x or pitch %d for color plane %d\n",
|
"Bad offset 0x%08x or pitch %d for color plane %d\n",
|
||||||
fb->offsets[color_plane], fb->pitches[color_plane],
|
fb->offsets[color_plane], fb->pitches[color_plane],
|
||||||
|
@ -73,20 +73,6 @@ bool i915_error_injected(void);
|
|||||||
__i915_printk(i915, i915_error_injected() ? KERN_DEBUG : KERN_ERR, \
|
__i915_printk(i915, i915_error_injected() ? KERN_DEBUG : KERN_ERR, \
|
||||||
fmt, ##__VA_ARGS__)
|
fmt, ##__VA_ARGS__)
|
||||||
|
|
||||||
#if defined(GCC_VERSION) && GCC_VERSION >= 70000
|
|
||||||
#define add_overflows_t(T, A, B) \
|
|
||||||
__builtin_add_overflow_p((A), (B), (T)0)
|
|
||||||
#else
|
|
||||||
#define add_overflows_t(T, A, B) ({ \
|
|
||||||
typeof(A) a = (A); \
|
|
||||||
typeof(B) b = (B); \
|
|
||||||
(T)(a + b) < a; \
|
|
||||||
})
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define add_overflows(A, B) \
|
|
||||||
add_overflows_t(typeof((A) + (B)), (A), (B))
|
|
||||||
|
|
||||||
#define range_overflows(start, size, max) ({ \
|
#define range_overflows(start, size, max) ({ \
|
||||||
typeof(start) start__ = (start); \
|
typeof(start) start__ = (start); \
|
||||||
typeof(size) size__ = (size); \
|
typeof(size) size__ = (size); \
|
||||||
|
Loading…
Reference in New Issue
Block a user