From: Ian Rogers <irogers@google.com>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: linux1394-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
Elkin Cruz <elkin@google.com>, Ian Rogers <irogers@google.com>
Subject: [PATCH] firewire: core: widen fw_node max_depth and max_hops to u8
Date: Thu, 19 Nov 2026 09:07:47 -0800 [thread overview]
Message-ID: <20261119170747.1525767-1-irogers@google.com> (raw)
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
reply other threads:[~2026-11-19 17:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261119170747.1525767-1-irogers@google.com \
--to=irogers@google.com \
--cc=elkin@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=llvm@lists.linux.dev \
--cc=o-takashi@sakamocchi.jp \
/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®