Thread (16 messages) 16 messages, 3 authors, 2026-02-21

Re: [PATCH v5 0/3] hwmon: Add support for the LTC4283 Hot Swap Controller

From: Guenter Roeck <linux@roeck-us.net>
Date: 2026-01-27 17:39:16
Also in: linux-doc, linux-gpio, linux-hwmon

Hi Nuno,

On 12/23/25 04:21, Nuno Sá via B4 Relay wrote:
This is v3 for the LTC4283 how swap controller. Main change is that I'm
now using the auxiliary bus for adding the GPIO device (done depending
on FW properties).

Similar to the LTC4282 device, we're clearing some fault logs in the
reset_history attributes.
I ran the patch series through an AI review. Results are below.
Please take a look.

Thanks,
Guenter

---
# Deep Dive Regression Analysis Log
Date: 2026-01-27

## Commit 5998c620fbd8: gpio: gpio-ltc4283: Add support for the LTC4283 Swap Controller

**Context**:
- Adds a new GPIO driver `drivers/gpio/gpio-ltc4283.c`.
- Depends on `drivers/hwmon/ltc4283.c` for regmap and MFD instantiation.

**Findings**:
1.  **Typo/Naming Issue**:
     - File `drivers/gpio/gpio-ltc4283.c` uses `LTC42823_ADIO_CONFIG` definition.
     - `LTC42823` appears to be a typo for `LTC4283`.
     - `drivers/gpio/gpio-ltc4283.c:26`: `#define LTC42823_ADIO_CONFIG 0x12`

2.  **Logic Verification**:
     - GPIO direction and value setting logic appears consistent with bitmasks provided, assuming register `0x12` and `0x11` layout is correct as inferred.

3.  **Regressions**:
     - No critical functional regressions found in this commit alone.
     - Code quality: Typo in macro name.

## Commit 82433332ce16: hwmon: ltc4283: Add support for the LTC4283 Swap Controller

**Context**:
- Adds core HWMON driver `drivers/hwmon/ltc4283.c`.
- Handles I2C communication, regmap initialization, and MFD child creation.

**Findings**:
1.  **Critical Regression: DebugFS Use-After-Free**:
     - `ltc4283_probe` calls `ltc4283_debugfs_init`.
     - `ltc4283_debugfs_init` calls `debugfs_create_file_unsafe` creating files associated with `st`.
     - `st` is allocated with `devm_kzalloc`.
     - **Issue**: There is no explicit cleanup of debugfs entries (e.g., `debugfs_remove_recursive`) and no `devm_add_action` to handle it.
     - **Consequence**: When the driver is unbound/unloaded, `st` is freed by devm. The debugfs entries remain. Accessing them triggers a Use-After-Free on `st`.
     - **Fix Required**: Use `devm_add_action_or_reset` to remove debugfs directory/entries on driver detach.

2.  **Typo**:
     - `drivers/hwmon/ltc4283.c:1765`: `MODULE_DESCRIPTION("LTC4283 How Swap Controller driver");`
     - "How Swap" should be "Hot Swap".

3.  **Property Handling**:
     - Driver respects "missing property" by keeping hardware/EEPROM defaults, while Bindings document specific defaults. This is a minor consistency issue but likely acceptable if EEPROM usually matches defaults.

## Commit a175d04e5900: dt-bindings: hwmon: Document the LTC4283 Swap Controller

**Context**:
- Adds DT bindings.

**Findings**:
- Bindings appear correct and consistent with driver usage.
- Dependencies logic (`adi,external-fault-retry-enable` requiring `adi,pgio4-func` to not be `gpio`) is enforced in both YAML and Driver.

## Summary

**Final Regressions Found**: 1 Major (DebugFS UAF), 2 Minor (Typos).

1.  **Major**: `drivers/hwmon/ltc4283.c`: DebugFS entries are not removed on driver unload, leading to UAF.
2.  **Minor**: `drivers/gpio/gpio-ltc4283.c`: `LTC42823_ADIO_CONFIG` typo.
3.  **Minor**: `drivers/hwmon/ltc4283.c`: `MODULE_DESCRIPTION` "How Swap" typo.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help