drm/i915: be more solid in checking the alignment
commit 1d61c5d711a2dc0b978ae905535edee9601f9449 upstream. The alignment is u64, and yet is_power_of_2() assumes unsigned long, which might give different results between 32b and 64b kernel. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: https://patchwork.freedesktop.org/patch/msgid/20200305203534.210466-1-matthew.auld@intel.com Cc: stable@vger.kernel.org (cherry picked from commit 2920516b2f719546f55079bc39a7fe409d9e80ab) Signed-off-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
40c4ad7f1b
commit
105d663d84
@ -439,7 +439,8 @@ eb_validate_vma(struct i915_execbuffer *eb,
|
||||
if (unlikely(entry->flags & eb->invalid_flags))
|
||||
return -EINVAL;
|
||||
|
||||
if (unlikely(entry->alignment && !is_power_of_2(entry->alignment)))
|
||||
if (unlikely(entry->alignment &&
|
||||
!is_power_of_2_u64(entry->alignment)))
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
|
@ -233,6 +233,11 @@ static inline u64 ptr_to_u64(const void *ptr)
|
||||
__idx; \
|
||||
})
|
||||
|
||||
static inline bool is_power_of_2_u64(u64 n)
|
||||
{
|
||||
return (n != 0 && ((n & (n - 1)) == 0));
|
||||
}
|
||||
|
||||
static inline void __list_del_many(struct list_head *head,
|
||||
struct list_head *first)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user