mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
To: Ian Rogers <irogers@google.com>, Manivannan Sadhasivam <mani@kernel.org>
Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
	Elkin Cruz <elkin@google.com>
Subject: Re: [PATCH] bus: mhi: host: Fix uninitialized status handling on BHI/BHIe read errors
Date: Mon, 30 Nov 2026 19:19:56 -0700	[thread overview]
Message-ID: <79129bf6-5103-4a68-8b41-aa447a55b4f2@oss.qualcomm.com> (raw)
In-Reply-To: <20261119170424.1512172-1-irogers@google.com>

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@google.com>
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>

      reply	other threads:[~2026-12-01  2:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 17:04 Ian Rogers
2026-12-01  2:19 ` Jeff Hugo [this message]

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=79129bf6-5103-4a68-8b41-aa447a55b4f2@oss.qualcomm.com \
    --to=jeff.hugo@oss.qualcomm.com \
    --cc=elkin@google.com \
    --cc=irogers@google.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mani@kernel.org \
    --cc=mhi@lists.linux.dev \
    /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®