Commit 91f00ab
committed
iio: trx-rf: ad9088: fix __counted_by misuse in ad9088_clk_register()
clk_hw_onecell_data::hws is a flexible array annotated with
__counted_by(num). Using hws[num++] to append clocks is, in theory,
correct from a sequence point perspective (the post-increment in a
subscript is well-defined in C), but it triggers -Wsequence-point
warnings with recent GCC versions. More importantly, it violates the
__counted_by contract: the array is accessed at index num before the
counter is incremented, triggering runtime UBSAN bounds checks.
Fix this by indexing hws with the source enum directly (which already
indexes into phy->clks[]) and setting clk_data->num once upfront in
ad9088_probe().
Signed-off-by: Nuno Sá <nuno.sa@analog.com>1 parent acce9f0 commit 91f00ab
1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1222 | 1222 | | |
1223 | 1223 | | |
1224 | 1224 | | |
1225 | | - | |
| 1225 | + | |
1226 | 1226 | | |
1227 | 1227 | | |
1228 | 1228 | | |
| |||
5215 | 5215 | | |
5216 | 5216 | | |
5217 | 5217 | | |
| 5218 | + | |
| 5219 | + | |
| 5220 | + | |
| 5221 | + | |
| 5222 | + | |
5218 | 5223 | | |
5219 | 5224 | | |
5220 | 5225 | | |
| |||
0 commit comments