Re: [PATCH v2] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()

From: Josh Poimboeuf

Date: Tue Mar 10 2026 - 12:30:02 EST


On Tue, Mar 10, 2026 at 01:36:16PM +0200, Andy Shevchenko wrote:
> 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.)

I'll be out the rest of this week, but I'll take a look when I get back.

> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>

Thanks!

--
Josh