From: Zhang Lixu lixu.zhang@intel.com
[ Upstream commit daeed86b686855adda79f13729e0c9b0530990be ]
The ishtp_cl_bus_match() function previously only checked the first entry in the driver's device ID table. Update it to iterate over the entire table, allowing proper matching for drivers with multiple supported protocol GUIDs.
Signed-off-by: Zhang Lixu lixu.zhang@intel.com Acked-by: Srinivas Pandruvada srinivas.pandruvada@linux.intel.com Signed-off-by: Benjamin Tissoires bentiss@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
## Analysis of Commit: HID: intel-ish-hid: Update ishtp bus match to support device ID table
### 1. COMMIT MESSAGE ANALYSIS
The commit message clearly describes: - **The problem**: The `ishtp_cl_bus_match()` function only checked the first entry (`id[0]`) in the driver's device ID table - **The fix**: Iterate over the entire ID table - **The purpose**: Allow proper matching for drivers with multiple supported protocol GUIDs
No "Fixes:" tag or "Reported-by:" tag is present (expected for commits under manual review).
### 2. CODE CHANGE ANALYSIS
**Before (buggy code):** ```c return(device->fw_client ? guid_equal(&driver->id[0].guid, &device->fw_client->props.protocol_name) : 0); ``` Only checks the **first entry** (`driver->id[0]`) in the device ID table.
**After (fixed code):** ```c if (client) { for (id = driver->id; !guid_is_null(&id->guid); id++) { if (guid_equal(&id->guid, &client->props.protocol_name)) return 1; } } return 0; ``` Properly iterates through **all entries** until finding a match or hitting the null GUID terminator.
**Root cause**: Logic error - incomplete iteration through device ID table. This is objectively incorrect behavior for a bus match function. Standard Linux bus matching iterates through all device IDs in a driver's table.
**Technical mechanism**: When a device with a protocol GUID that matches the 2nd, 3rd, or later entry in a driver's ID table is enumerated, the old code would fail to match, leaving the device without a driver.
### 3. CLASSIFICATION
- **Bug fix**: Yes - this fixes fundamentally broken device matching logic - **New feature**: No - it corrects existing functionality to work as designed - **Exception category**: Not needed - it's a straightforward bug fix
### 4. SCOPE AND RISK ASSESSMENT
- **Lines changed**: ~10 lines of actual code - **Files touched**: 1 (drivers/hid/intel-ish-hid/ishtp/bus.c) - **Complexity**: Low - simple loop structure following standard patterns - **Subsystem**: Intel ISH (Integrated Sensor Hub) HID driver - **Risk**: Very low - if wrong, devices wouldn't match (no crashes/corruption)
The change follows the standard Linux bus matching pattern used across the kernel (iterate until null terminator).
### 5. USER IMPACT
- **Affected users**: Intel ISH users with drivers supporting multiple protocol GUIDs - **Severity**: Medium - affected devices simply wouldn't work (wouldn't bind to their driver) - **Real bug**: Yes - the code was objectively wrong
### 6. STABILITY INDICATORS
- **Acked-by**: Srinivas Pandruvada (Intel ISH maintainer) - **Signed-off-by**: Benjamin Tissoires (HID subsystem maintainer) - Pattern follows well-established Linux driver matching conventions
### 7. DEPENDENCY CHECK
- Self-contained, no dependencies on other commits - The `ishtp_cl_bus_match()` function exists in stable trees - No new APIs or infrastructure required
### RISK VS BENEFIT TRADE-OFF
**Benefits:** - Fixes obviously incorrect code in bus matching - Enables proper device/driver matching for drivers with multiple IDs - Small, surgical, low-risk change - Follows standard kernel patterns
**Risks:** - Minimal - only affects ISH device matching - Failure mode is "device doesn't match" not crash/corruption
**Concerns:** - No explicit bug report showing users hitting this - Could be seen as enabling new functionality if no drivers currently use multiple IDs
### CONCLUSION
This commit fixes objectively incorrect behavior in the ISHTP bus matching function. The old code only checking `id[0]` is clearly wrong for a device ID table that's designed to hold multiple entries. The fix is small, surgical, follows standard kernel patterns, and has low risk. Even without an explicit user report, fixing fundamentally broken matching logic is appropriate for stable trees. The change is acked by the Intel maintainer and the HID subsystem maintainer.
The fix is self-contained, doesn't introduce new APIs, and corrects a logic error that would prevent devices from working if their GUID wasn't first in the table.
**YES**
drivers/hid/intel-ish-hid/ishtp/bus.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c index 93a0432e70581..8e9f5a28e62ec 100644 --- a/drivers/hid/intel-ish-hid/ishtp/bus.c +++ b/drivers/hid/intel-ish-hid/ishtp/bus.c @@ -240,9 +240,17 @@ static int ishtp_cl_bus_match(struct device *dev, const struct device_driver *dr { struct ishtp_cl_device *device = to_ishtp_cl_device(dev); struct ishtp_cl_driver *driver = to_ishtp_cl_driver(drv); + struct ishtp_fw_client *client = device->fw_client; + const struct ishtp_device_id *id;
- return(device->fw_client ? guid_equal(&driver->id[0].guid, - &device->fw_client->props.protocol_name) : 0); + if (client) { + for (id = driver->id; !guid_is_null(&id->guid); id++) { + if (guid_equal(&id->guid, &client->props.protocol_name)) + return 1; + } + } + + return 0; }
/**