✗ CI.checkpatch: warning for drm/i915/backlight: Return immediately when scale() finds invalid parameters
Patchwork
patchwork at emeril.freedesktop.org
Tue Jan 21 10:53:06 UTC 2025
== Series Details ==
Series: drm/i915/backlight: Return immediately when scale() finds invalid parameters
URL : https://patchwork.freedesktop.org/series/143773/
State : warning
== Summary ==
+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt
Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master
30ab6715fc09baee6cc14cb3c89ad8858688d474
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit af927bced9c1c96e9512db4a7f3c7ad1888d107c
Author: Guenter Roeck <linux at roeck-us.net>
Date: Mon Jan 20 22:17:46 2025 -0800
drm/i915/backlight: Return immediately when scale() finds invalid parameters
The scale() functions detects invalid parameters, but continues
its calculations anyway. This causes bad results if negative values
are used for unsigned operations. Worst case, a division by 0 error
will be seen if source_min == source_max.
On top of that, after v6.13, the sequence of WARN_ON() followed by clamp()
may result in a build error with gcc 13.x.
drivers/gpu/drm/i915/display/intel_backlight.c: In function 'scale':
include/linux/compiler_types.h:542:45: error:
call to '__compiletime_assert_415' declared with attribute error:
clamp() low limit source_min greater than high limit source_max
This happens if the compiler decides to rearrange the code as follows.
if (source_min > source_max) {
WARN(..);
/* Do the clamp() knowing that source_min > source_max */
source_val = clamp(source_val, source_min, source_max);
} else {
/* Do the clamp knowing that source_min <= source_max */
source_val = clamp(source_val, source_min, source_max);
}
Fix the problem by evaluating the return values from WARN_ON and returning
immediately after a warning. While at it, fix divide by zero error seen
if source_min == source_max.
Analyzed-by: Linus Torvalds <torvalds at linux-foundation.org>
Suggested-by: Linus Torvalds <torvalds at linux-foundation.org>
Suggested-by: David Laight <david.laight.linux at gmail.com>
Cc: David Laight <david.laight.linux at gmail.com>
Cc: Jani Nikula <jani.nikula at linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
Signed-off-by: Guenter Roeck <linux at roeck-us.net>
+ /mt/dim checkpatch 7727d97a1f38c61a60e87b2d38f7cc5a4aae277b drm-intel
af927bced9c1 drm/i915/backlight: Return immediately when scale() finds invalid parameters
-:35: WARNING:BAD_SIGN_OFF: Non-standard signature: Analyzed-by:
#35:
Analyzed-by: Linus Torvalds <torvalds at linux-foundation.org>
total: 0 errors, 1 warnings, 0 checks, 13 lines checked
More information about the Intel-xe
mailing list