* [PATCH] firewire: core: widen fw_node max_depth and max_hops to u8
@ 2026-11-19 17:07 Ian Rogers
0 siblings, 0 replies; only message in thread
From: Ian Rogers @ 2026-11-19 17:07 UTC (permalink / raw)
To: Takashi Sakamoto
Cc: linux1394-devel, linux-kernel, llvm, Elkin Cruz, Ian Rogers
In bm_work(), FireWire bus management checks
'root_node->max_hops < ARRAY_SIZE(gap_count_table)' (16) so that IEEE 1394
topologies with 16 or more hops (up to 63 nodes / 62 hops per IEEE 1394a)
fall back to expected_gap_count = 63. However, struct fw_node declares
max_depth and max_hops as 4-bit unsigned bitfields (0..15). On topologies
with >= 16 hops, update_hop_count() truncates max_depth and max_hops
modulo 16 (for example 19 hops wraps to 3), causing bm_work() to program a
too-small gap count (8 instead of 63) and trigger arbitration failures.
Change max_depth and max_hops from 4-bit bitfields to u8. Because both
fields occupy existing alignment padding ahead of struct kref in
struct fw_node, sizeof(struct fw_node) is unchanged.
Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
-Wtautological-value-range-compare enabled; fix and changelog drafted with
an AI coding assistant. Verified with an ASan/UBSan C struct-size and
19-hop topology test, and build-tested under LLVM=1 W=1 (-Werror) and
-Wtautological-value-range-compare; not tested on physical IEEE 1394
hardware.
Fixes: 83db801ce8c6 ("firewire: Implement gap count optimization.")
Signed-off-by: Ian Rogers <irogers@google.com>
---
drivers/firewire/core.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
index 8b49d7480c37..ca2150f75174 100644
--- a/drivers/firewire/core.h
+++ b/drivers/firewire/core.h
@@ -207,8 +207,8 @@ struct fw_node {
u8 phy_speed:2; /* As in the self ID packet. */
u8 max_speed:2; /* Minimum of all phy-speeds on the path from the
* local node to this node. */
- u8 max_depth:4; /* Maximum depth to any leaf node */
- u8 max_hops:4; /* Max hops in this sub tree */
+ u8 max_depth; /* Maximum depth to any leaf node */
+ u8 max_hops; /* Max hops in this sub tree */
struct kref kref;
--
2.56.1.708.g77570a6a1d-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-19 17:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 17:07 [PATCH] firewire: core: widen fw_node max_depth and max_hops to u8 Ian Rogers
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®