some objtool warnings fixes
Subsystems (5)
Josh Poimboeuf
maintainercover some objtool warnings fixes
Some fixes for objtool warnings reported by Arnd.
Josh Poimboeuf (3):
objtool: Fix Clang jump table detection
ASoC: codecs: wcd9335: Remove potential undefined behavior in
wcd9335_slimbus_irq()
iio: imu: bmi160: Remove potential undefined behavior in
bmi160_config_pin()drivers/iio/imu/bmi160/bmi160_core.c | 2 ++ sound/soc/codecs/wcd9335.c | 2 +- tools/objtool/check.c | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.53.0
Josh Poimboeuf
maintainerPATCH 1/3 objtool: Fix Clang jump table detection
With Clang, there can be a conditional forward jump between the load of the jump table address and the indirect branch.
Fixes the following warning:
vmlinux.o: warning: objtool: ___bpf_prog_run+0x1c5: sibling call from callable instruction with modified stack frame
--- tools/objtool/check.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/objtool/check.c +2 -3
@@ -2184,12 +2184,11 @@ static void mark_func_jump_tables(struct objtool_file *file, last = insn;/* -* Store back-pointers for unconditional forward jumps such +* Store back-pointers for forward jumps such * that find_jump_table() can back-track using those and * avoid some potentially confusing code. */ -if (insn->type ==INSN_JUMP_UNCONDITIONAL && insn->jump_dest && - insn->offset > last->offset && +if (insn->jump_dest && insn->jump_dest->offset > insn->offset && !insn->jump_dest->first_jump_src) {
Signature · 1 line
2.53.0
Josh Poimboeuf
maintainerPATCH 2/3 ASoC: codecs: wcd9335: Remove potential undefined behavior in wcd9335_slimbus_irq()
In reply to Josh PoimboeufIf 'port_id' is negative, the shift counts in wcd9335_slimbus_irq() also become negative, resulting in undefined behavior due to shift out of bounds.
That appears to be not possible, but with UBSAN enabled, Clang's range analysis isn't always able to determine that and generates undefined behavior.
As a result the code generation isn't optimal, and undefined behavior should be avoided regardless. Improve code generation and remove the undefined behavior by converting the signed variables to unsigned.
Fixes the following warning:
sound/soc/codecs/wcd9335.o: warning: objtool: wcd9335_slimbus_irq() falls through to next function __cfi_wcd9335_set_channel_map()
This is very similar to a previous fix to wcd934x with commit 060aed9c0093 ("objtool, ASoC: codecs: wcd934x: Remove potential undefined behavior in wcd934x_slim_irq_handler()").
--- sound/soc/codecs/wcd9335.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wcd9335.c +1 -1
@@ -3907,7 +3907,7 @@ static irqreturn_t wcd9335_slimbus_irq(int irq, void *data) {struct wcd9335_codec *wcd = data;unsigned long status =0 ; -int i, j, port_id; +unsigned int i, j, port_id;unsigned int val, int_val =0 ;irqreturn_t ret =IRQ_NONE ;bool tx;
Signature · 1 line
2.53.0
Josh Poimboeuf
maintainerPATCH 3/3 iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
In reply to Josh PoimboeufIf '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.
--- drivers/iio/imu/bmi160/bmi160_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/imu/bmi160/bmi160_core.c +2 -0
@@ -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;
Signature · 1 line
2.53.0
Mark Brown
maintainerRe: [PATCH 2/3] ASoC: codecs: wcd9335: Remove potential undefined behavior in wcd9335_slimbus_irq()
In reply to Josh PoimboeufQuoted 3 lines · Josh Poimboeuf
If '
port_id' is negative, the shift counts inwcd9335_slimbus_irq()also become negative, resulting in undefined behavior due to shift out of bounds.
You've not copied me on the rest of the series so I don't know what's going on with dependencies. When sending a patch series it is important to ensure that all the various maintainers understand what the relationship between the patches as the expecation is that there will be interdependencies. Either copy everyone on the whole series or at least copy them on the cover letter and explain what's going on. If there are no strong interdependencies then it's generally simplest to just send the patches separately to avoid any possible confusion.
Josh Poimboeuf
maintainerRe: [PATCH 2/3] ASoC: codecs: wcd9335: Remove potential undefined behavior in wcd9335_slimbus_irq()
Quoted 5 lines · Mark Brown
Quoted 3 lines · Josh Poimboeuf
If '
port_id' is negative, the shift counts inwcd9335_slimbus_irq()also become negative, resulting in undefined behavior due to shift out of bounds.
Quoted 8 lines
You've not copied me on the rest of the series so I don't know what's going on with dependencies. When sending a patch series it is important to ensure that all the various maintainers understand what the relationship between the patches as the expecation is that there will be interdependencies. Either copy everyone on the whole series or at least copy them on the cover letter and explain what's going on. If there are no strong interdependencies then it's generally simplest to just send the patches separately to avoid any possible confusion.
Sorry about that. This is just a collection of objtool warnings fixes and there are no interdependencies.
Signature · 1 line
Josh
Re: [PATCH 3/3] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
In reply to Josh PoimboeufQuoted 35 lines · Josh Poimboeuf
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 <[email protected]>Cc David Lechner <[email protected]>CC Nuno Sá <[email protected]>Cc Andy Shevchenko <[email protected]>Fixes 895bf81e6bbf ("iio:bmi160: add drdy interrupt support")Reported-by Arnd Bergmann <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>---
drivers/iio/imu/bmi160/bmi160_core.c | 2 ++1 file changed, 2 insertions(+)drivers/iio/imu/bmi160/bmi160_core.c +2
-0@@ -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;
Quoted 1 line
AFAIK, BUG() is not something we should use lightly so I wonder why having it rather that a normal 'return -EINVAL'?
At the very least, it could be WARN but I still think that's too much for a device .probe(). Any special reason using BUG()?
Also seems like:
https://elixir.bootlin.com/linux/v7.0-rc2/source/drivers/iio/imu/bmi160/bmi160_core.c#L624
could be improved? Like setting 'pin_name' in the first switch() case.
- Nuno Sá
Josh Poimboeuf
maintainerRe: [PATCH 3/3] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
Quoted 41 lines · Nuno Sá
Quoted 35 lines · Josh Poimboeuf
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 <[email protected]>Cc David Lechner <[email protected]>CC Nuno Sá <[email protected]>Cc Andy Shevchenko <[email protected]>Fixes 895bf81e6bbf ("iio:bmi160: add drdy interrupt support")Reported-by Arnd Bergmann <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>---
drivers/iio/imu/bmi160/bmi160_core.c | 2 ++1 file changed, 2 insertions(+)drivers/iio/imu/bmi160/bmi160_core.c +2
-0@@ -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;Quoted 1 line
AFAIK,
BUG()is not something we should use lightly so I wonder why having it rather that a normal 'return-EINVAL'?
Quoted 2 lines
At the very least, it could be WARN but I still think that's too much for a device .probe(). Any special reason using
BUG()?
Using BUG() for a default "invalid enum" is a common pattern, but indeed returning an error would also be valid here. I can change that to return -EINVAL.
Quoted 5 lines
Also seems like:
https://elixir.bootlin.com/linux/v7.0-rc2/source/drivers/iio/imu/bmi160/bmi160_core.c#L624
could be improved? Like setting '
pin_name' in the firstswitch()case.
Yeah, I assume you mean setting 'pin_name' to something like "invalid" for the default case?
Signature · 1 line
Josh
Re: [PATCH 3/3] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
Quoted 52 lines · Josh Poimboeuf
Quoted 44 lines · Nuno Sá
Quoted 37 lines · Josh Poimboeuf
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 <[email protected]>Cc David Lechner <[email protected]>CC Nuno Sá <[email protected]>Cc Andy Shevchenko <[email protected]>Fixes 895bf81e6bbf ("iio:bmi160: add drdy interrupt support")Reported-by Arnd Bergmann <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>---
drivers/iio/imu/bmi160/bmi160_core.c | 2 ++1 file changed, 2 insertions(+)drivers/iio/imu/bmi160/bmi160_core.c +2
-0@@ -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;Quoted 1 line
AFAIK,
BUG()is not something we should use lightly so I wonder why having it rather that a normal
'return-EINVAL'?Quoted 2 lines
At the very least, it could be WARN but I still think that's too much for a device .probe(). Any special reason using
BUG()?Using
BUG()for a default "invalid enum" is a common pattern, but indeed returning an error would also be valid here. I can change that to return-EINVAL.
Quoted 8 lines
Quoted 5 lines
Also seems like:
https://elixir.bootlin.com/linux/v7.0-rc2/source/drivers/iio/imu/bmi160/bmi160_core.c#L624
could be improved? Like setting '
pin_name' in the firstswitch()case.Yeah, I assume you mean setting '
pin_name' to something like "invalid" for the default case?
Nope, I meant not duplicating the switch() case. The default should return an error so I would say no need to bother in setting the name for that case.
- Nuno Sá
Re: [PATCH 3/3] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
In reply to Josh PoimboeufQuoted 8 lines · Josh Poimboeuf
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()
Quoted 7 lines
Prevent the UB and improve error handling by adding a
BUG()if 'pin' has an unexpected value.Cc Jonathan Cameron <[email protected]>Cc David Lechner <[email protected]>CC Nuno Sá <[email protected]>Cc Andy Shevchenko <[email protected]>
Please, reduce the noise in the commit message by moving Cc list to be below the '---' line. This will have the same effect on email (Git tools work fine) and if anybody needs this information it will be preserved in lore.kernel.org archive. In case you have questions about handling this locally, there is a subthread (patch 18) of this series:
https://lore.kernel.org/lkml/[email protected]/
Signature · 2 lines
With Best Regards, Andy Shevchenko
Josh Poimboeuf
maintainerRe: [PATCH 3/3] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
In reply to Nuno SáQuoted 57 lines · Nuno Sá
Quoted 56 lines · Josh Poimboeuf
Quoted 44 lines · Nuno Sá
Quoted 37 lines · Josh Poimboeuf
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 <[email protected]>Cc David Lechner <[email protected]>CC Nuno Sá <[email protected]>Cc Andy Shevchenko <[email protected]>Fixes 895bf81e6bbf ("iio:bmi160: add drdy interrupt support")Reported-by Arnd Bergmann <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>---
drivers/iio/imu/bmi160/bmi160_core.c | 2 ++1 file changed, 2 insertions(+)drivers/iio/imu/bmi160/bmi160_core.c +2
-0@@ -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;Quoted 1 line
AFAIK,
BUG()is not something we should use lightly so I wonder why having it rather that a normal
'return-EINVAL'?Quoted 2 lines
At the very least, it could be WARN but I still think that's too much for a device .probe(). Any special reason using
BUG()?Using
BUG()for a default "invalid enum" is a common pattern, but indeed returning an error would also be valid here. I can change that to return-EINVAL.Quoted 4 lines
Also seems like:
https://elixir.bootlin.com/linux/v7.0-rc2/source/drivers/iio/imu/bmi160/bmi160_core.c#L624
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
could be improved? Like setting '
pin_name' in the firstswitch()case.Yeah, I assume you mean setting '
pin_name' to something like "invalid" for the default case?Nope, I meant not duplicating the
switch()case. The default should return an error so I would say no need to bother in setting the name for that case.
Ah, you mean combining the switch() statements into one. Ok, I'll do that.
Signature · 1 line
Josh
David Lechner
reviewerRe: [PATCH 3/3] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
In reply to Andy ShevchenkoQuoted 17 lines · Andy Shevchenko
Quoted 8 lines · Josh Poimboeuf
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()Quoted 7 lines
Prevent the UB and improve error handling by adding a
BUG()if 'pin' has an unexpected value.Cc Jonathan Cameron <[email protected]>Cc David Lechner <[email protected]>CC Nuno Sá <[email protected]>Cc Andy Shevchenko <[email protected]>
Quoted 7 lines
Please, reduce the noise in the commit message by moving Cc list to be below the '---' line. This will have the same effect on email (Git tools work fine) and if anybody needs this information it will be preserved in lore.kernel.org archive. In case you have questions about handling this locally, there is a subthread (patch 18) of this series:
https://lore.kernel.org/lkml/[email protected]/
And be sure to include the IIO mailing list too, not just the maintainers/ reviewers. Omitting it breaks some workflows.
Josh Poimboeuf
maintainerRe: [PATCH 3/3] iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()
In reply to Andy ShevchenkoQuoted 17 lines · Andy Shevchenko
Quoted 8 lines · Josh Poimboeuf
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()Quoted 7 lines
Prevent the UB and improve error handling by adding a
BUG()if 'pin' has an unexpected value.Cc Jonathan Cameron <[email protected]>Cc David Lechner <[email protected]>CC Nuno Sá <[email protected]>Cc Andy Shevchenko <[email protected]>
Quoted 6 lines
Please, reduce the noise in the commit message by moving Cc list to be below the '---' line. This will have the same effect on email (Git tools work fine) and if anybody needs this information it will be preserved in lore.kernel.org archive. In case you have questions about handling this locally, there is a subthread (patch 18) of this series:
https://lore.kernel.org/lkml/[email protected]/
Will do, thanks.
Signature · 1 line
Josh
Re: [PATCH 2/3] ASoC: codecs: wcd9335: Remove potential undefined behavior in wcd9335_slimbus_irq()
In reply to Josh PoimboeufQuoted 20 lines · Josh Poimboeuf
If '
port_id' is negative, the shift counts inwcd9335_slimbus_irq()also become negative, resulting in undefined behavior due to shift out of bounds.That appears to be not possible, but with UBSAN enabled, Clang's range analysis isn't always able to determine that and generates undefined behavior.
As a result the code generation isn't optimal, and undefined behavior should be avoided regardless. Improve code generation and remove the undefined behavior by converting the signed variables to unsigned.
Fixes the following warning:
sound/soc/codecs/wcd9335.o: warning: objtool:wcd9335_slimbus_irq()falls through to next function__cfi_wcd9335_set_channel_map()This is very similar to a previous fix to wcd934x with commit
060aed9c0093("objtool, ASoC: codecs: wcd934x: Remove potential undefined behavior inwcd934x_slim_irq_handler()").
Quoted 7 lines
Cc Srinivas Kandagatla <[email protected]>Cc Liam Girdwood <[email protected]>Cc Mark Brown <[email protected]>Reported-by Arnd Bergmann <[email protected]>Signed-off-by Josh Poimboeuf <[email protected]>---
Am not sure if port_id will be ever negative. but the change itself looks harmless,
--srini
Quoted 16 lines
sound/soc/codecs/wcd9335.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)sound/soc/codecs/wcd9335.c +1
-1@@ -3907,7 +3907,7 @@ static irqreturn_t wcd9335_slimbus_irq(int irq, void *data) {struct wcd9335_codec *wcd = data;unsigned long status =0 ; -int i, j, port_id; +unsigned int i, j, port_id;unsigned int val, int_val =0 ;irqreturn_t ret =IRQ_NONE ;bool tx;
Mark Brown
maintainerRe: (subset) [PATCH 0/3] some objtool warnings fixes
In reply to Josh PoimboeufQuoted 10 lines · Josh Poimboeuf
Some fixes for objtool warnings reported by Arnd.
Josh Poimboeuf (3):
objtool: Fix Clang jump table detection
ASoC: codecs: wcd9335: Remove potential undefined behavior inwcd9335_slimbus_irq() iio: imu: bmi160: Remove potential undefined behavior in bmi160_config_pin()[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[2/3] ASoC: codecs: wcd9335: Remove potential undefined behavior in wcd9335_slimbus_irq()
commit: ed0313223ce6514dbd39c049e25f702980d7e3cc
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
[tip: objtool/urgent] objtool: Fix Clang jump table detection
In reply to Josh PoimboeufThe following commit has been merged into the objtool/urgent branch of tip:
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: 4e5019216402ad0b4a84cff457b662d26803f103 Gitweb: https://git.kernel.org/tip/4e5019216402ad0b4a84cff457b662d26803f103 Author: Josh Poimboeuf <[email protected]> AuthorDate: Mon, 09 Mar 2026 09:03:05 -07:00 Committer: Josh Poimboeuf <[email protected]> CommitterDate: Mon, 16 Mar 2026 15:31:25 -07:00
objtool: Fix Clang jump table detection
With Clang, there can be a conditional forward jump between the load of the jump table address and the indirect branch.
Fixes the following warning:
vmlinux.o: warning: objtool: ___bpf_prog_run+0x1c5: sibling call from callable instruction with modified stack frame
--- tools/objtool/check.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/objtool/check.c +2 -3
@@ -2184,12 +2184,11 @@ static void mark_func_jump_tables(struct objtool_file *file, last = insn;/* -* Store back-pointers for unconditional forward jumps such +* Store back-pointers for forward jumps such * that find_jump_table() can back-track using those and * avoid some potentially confusing code. */ -if (insn->type ==INSN_JUMP_UNCONDITIONAL && insn->jump_dest && - insn->offset > last->offset && +if (insn->jump_dest && insn->jump_dest->offset > insn->offset && !insn->jump_dest->first_jump_src) {