Re: [PATCH] bus: mhi: host: Fix uninitialized status handling on BHI/BHIe read errors

From: Jeff Hugo

Date: Mon Nov 30 2026 - 21:20:03 EST


On 11/19/2026 10:04 AM, Ian Rogers wrote:
mhi_download_rddm_image(), mhi_fw_load_bhie(), and mhi_fw_load_bhi()
poll BHI/BHIe status registers inside wait_event_timeout() using:

mhi_read_reg_field(..., &status) || status

When mhi_read_reg_field() returns a non-zero error code before ever
writing *out, the short-circuit OR wakes wait_event_timeout() with a
positive return value while leaving status uninitialized on the stack:

- In mhi_fw_load_bhi(), only tx_status == BHI_STATUS_ERROR (0x3) is
treated as an error after wait_event_timeout(), so any register read
error where stack garbage is not 0x3 causes mhi_fw_load_bhi() to
return 0 (success) despite failing to read BHI_STATUS.
- In mhi_download_rddm_image() and mhi_fw_load_bhie(), status is
compared against BHIE_*_STATUS_XFER_COMPL (0x2), reading uninitialized
stack memory if the first register read fails.

Initialize rx_status and tx_status to their *_RESET (0) constants and
require tx_status == BHI_STATUS_SUCCESS after a non-timeout wakeup in
mhi_fw_load_bhi() so register read failures reliably return -EIO while
genuine timeouts still return -ETIMEDOUT.

Found by enabling Clang's -Wconditional-uninitialized on an x86_64
allyesconfig build, with AI coding assistant help to audit the warning
and prepare the fix. Build-tested with Clang; not runtime-tested on MHI
hardware.

Fixes: cd457afb1667 ("bus: mhi: core: Add support for downloading firmware over BHIe")
Fixes: 6fdfdd27328c ("bus: mhi: core: Add support for downloading RDDM image during panic")
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
Reviewed-by: Jeff Hugo <jeff.hugo@xxxxxxxxxxxxxxxx>