Re: [PATCH v2] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
From: Andy Shevchenko
Date: Tue Mar 10 2026 - 07:50:29 EST
On Mon, Mar 09, 2026 at 08:45:45PM -0700, Josh Poimboeuf wrote:
> If 'pin' is not one of its expected values, the value of
> 'int_out_ctrl_shift' is undefined. With UBSAN enabled, this causes
> Clang to generate undefined behavior, resulting in the following
> warning:
>
> drivers/iio/imu/bmi160/bmi160_core.o: warning: objtool: bmi160_setup_irq() falls through to next function __cfi_bmi160_core_runtime_resume()
>
> Prevent the UB and improve error handling by returning an error if 'pin'
> has an unexpected value.
>
> While at it, simplify the code a bit by moving the 'pin_name' assignment
> to the first switch statement.
Thanks!
Are you aware of this: https://bugzilla.kernel.org/show_bug.cgi?id=219192?
Perhaps also needs to be addressed? (I haven't checked if it's already done
or not.)
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
--
With Best Regards,
Andy Shevchenko