1. 23 Jun, 2023 1 commit
    • Nathan Chancellor's avatar
      leds: leds-mt6323: Adjust return/parameter types in wled get/set callbacks · 877e9119
      Nathan Chancellor authored
      Clang's kernel Control Flow Integrity (kCFI) is a compiler-based
      security mitigation that ensures the target of an indirect function call
      matches the expected type of the call and trapping if they do not match
      exactly. The warning -Wincompatible-function-pointer-types-strict aims
      to catch these issues at compile time, which reveals:
      
       drivers/leds/leds-mt6323.c:598:49: error: incompatible function pointer types assigning to 'int (*)(struct led_classdev *, enum led_brightness)' from 'int (struct led_classdev *, unsigned int)' [-Werror,-Wincompatible-function-pointer-types-strict]
         598 |                         leds->led[reg]->cdev.brightness_set_blocking =
             |                                                                      ^
         599 |                                                 mt6323_wled_set_brightness;
             |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
       drivers/leds/leds-mt6323.c:600:40: error: incompatible function pointer types assigning to 'enum led_brightness (*)(struct led_classdev *)' from 'unsigned int (struct led_classdev *)' [-Werror,-Wincompatible-function-pointer-types-strict]
         600 |                         leds->led[reg]->cdev.brightness_get =
             |                                                             ^
         601 |                                                 mt6323_get_wled_brightness;
             |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
       2 errors generated.
      
      While 'unsigned int' is ABI compatible with 'enum led_brightness' (hence
      no warning from -Wincompatible-function-pointer-types) and the callers
      of these callbacks use/pass the values as 'unsigned int', the mismatch
      between the prototype and the called function will trip kCFI at runtime.
      
      Change the types in the implementations to match the prototypes, clearing
      up the warning and avoiding kCFI failures.
      
      Fixes: 9bb0a9e0 ("leds: leds-mt6323: Add support for WLEDs and MT6332")
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20230622-mt6323-wled-wincompatible-function-pointer-types-strict-v1-1-6ad256f220e8@kernel.orgSigned-off-by: default avatarLee Jones <lee@kernel.org>
      877e9119
  2. 21 Jun, 2023 3 commits
  3. 15 Jun, 2023 2 commits
  4. 09 Jun, 2023 7 commits
  5. 08 Jun, 2023 8 commits
  6. 01 Jun, 2023 2 commits
  7. 25 May, 2023 17 commits