Re: [PATCH v2] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
From: Jonathan Cameron
Date: Sun Mar 15 2026 - 08:26:59 EST
On Tue, 10 Mar 2026 14:57:19 +0000
Nuno Sá <noname.nuno@xxxxxxxxx> wrote:
> On Mon, 2026-03-09 at 20:45 -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.
> >
> > Fixes: 895bf81e6bbf ("iio:bmi160: add drdy interrupt support")
> > Reported-by: Arnd Bergmann <arnd@xxxxxxxx>
> > Closes: https://lore.kernel.org/a426d669-58bb-4be1-9eaa-6f3d83109e2d@xxxxxxxxxxxxxxxx
> > Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> > ---
>
> Reviewed-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan