mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@kernel.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, "Arnd Bergmann" <arnd@arndb.de>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>
Subject: [PATCH 3/3] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
Date: Mon,  9 Mar 2026 09:03:07 -0700	[thread overview]
Message-ID: <84155f1de72b88d2841b16db97f47ffa4b0f747e.1773071992.git.jpoimboe@kernel.org> (raw)
In-Reply-To: <cover.1773071991.git.jpoimboe@kernel.org>

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 adding a BUG() if 'pin' has
an unexpected value.

Cc: Jonathan Cameron <jic23@kernel.org>
Cc: David Lechner <dlechner@baylibre.com>
CC: Nuno Sá <nuno.sa@analog.com>
Cc: Andy Shevchenko <andy@kernel.org>
Fixes: 895bf81e6bbf ("iio:bmi160: add drdy interrupt support")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Closes: https://lore.kernel.org/a426d669-58bb-4be1-9eaa-6f3d83109e2d@app.fastmail.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 drivers/iio/imu/bmi160/bmi160_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
index 5f47708b4c5d..e5326df75e49 100644
--- a/drivers/iio/imu/bmi160/bmi160_core.c
+++ b/drivers/iio/imu/bmi160/bmi160_core.c
@@ -579,6 +579,8 @@ static int bmi160_config_pin(struct regmap *regmap, enum bmi160_int_pin pin,
 		int_latch_mask = BMI160_INT2_LATCH_MASK;
 		int_map_mask = BMI160_INT2_MAP_DRDY_EN;
 		break;
+	default:
+		BUG();
 	}
 	int_out_ctrl_mask = BMI160_INT_OUT_CTRL_MASK << int_out_ctrl_shift;
 
-- 
2.53.0


  parent reply	other threads:[~2026-03-09 16:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09 16:03 [PATCH 0/3] some objtool warnings fixes Josh Poimboeuf
2026-03-09 16:03 ` [PATCH 1/3] objtool: Fix Clang jump table detection Josh Poimboeuf
2026-03-18  8:25   ` [tip: objtool/urgent] " tip-bot2 for Josh Poimboeuf
2026-03-09 16:03 ` [PATCH 2/3] ASoC: codecs: wcd9335: Remove potential undefined behavior in wcd9335_slimbus_irq() Josh Poimboeuf
2026-03-09 16:05   ` Mark Brown
2026-03-09 16:13     ` Josh Poimboeuf
2026-03-09 17:45   ` Srinivas Kandagatla
2026-03-09 16:03 ` Josh Poimboeuf [this message]
2026-03-09 16:16   ` [PATCH 3/3] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin() Nuno Sá
2026-03-09 16:27     ` Josh Poimboeuf
2026-03-09 16:31       ` Nuno Sá
2026-03-09 16:48         ` Josh Poimboeuf
2026-03-09 16:40   ` Andy Shevchenko
2026-03-09 16:52     ` David Lechner
2026-03-09 16:55     ` Josh Poimboeuf
2026-03-09 22:36 ` (subset) [PATCH 0/3] some objtool warnings fixes Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84155f1de72b88d2841b16db97f47ffa4b0f747e.1773071992.git.jpoimboe@kernel.org \
    --to=jpoimboe@kernel.org \
    --cc=andy@kernel.org \
    --cc=arnd@arndb.de \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®