mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
To: Linmao Li <lilinmao@kylinos.cn>,
	Sibi Sankar <sibi.sankar@oss.qualcomm.com>
Cc: "Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>,
	"Maya Matuszczyk" <maccraft123mc@gmail.com>,
	"Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>,
	"Konrad Dybcio" <konrad.dybcio@oss.qualcomm.com>,
	linux-arm-msm@vger.kernel.org,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform: arm64: qcom-hamoa-ec: reject incomplete responses
Date: Wed, 29 Jul 2026 15:38:45 +0530	[thread overview]
Message-ID: <d1a6474c-68c1-42f1-8d2d-ad5acdd25fd6@oss.qualcomm.com> (raw)
In-Reply-To: <20260728111924.4106898-1-lilinmao@kylinos.cn>



On 7/28/2026 4:49 PM, Linmao Li wrote:
> qcom_ec_read() accepts short positive transfers, while both callers
> unconditionally consume every field in their fixed-size response. A short
> transfer can therefore make them use trailing stack bytes that were not
> returned by the device.
> 
> The first response byte contains the number of payload bytes, excluding
> the byte count itself. A complete response of resp_len bytes must
> therefore report resp_len - 1 payload bytes. The existing check only
> rejects counts that do not fit in the response buffer and still accepts
> an incomplete payload.
> 
> Require both the SMBus transfer length and the EC-provided payload count
> to match the expected response size.
> 
> Fixes: 5c44f48e91de ("platform: arm64: Add driver for EC found on Qualcomm reference devices")
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
> ---
> The resp_len - 1 requirement is based solely on the response layouts
> documented in this driver. The EC specification and hardware were not
> available, so please confirm it for supported firmware revisions.
> 
> Compile-tested with CONFIG_EC_QCOM_HAMOA=m.
> 
>  drivers/platform/arm64/qcom-hamoa-ec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/arm64/qcom-hamoa-ec.c b/drivers/platform/arm64/qcom-hamoa-ec.c
> index 5ca7308c6077..4d2ad042a7f8 100644
> --- a/drivers/platform/arm64/qcom-hamoa-ec.c
> +++ b/drivers/platform/arm64/qcom-hamoa-ec.c
> @@ -92,8 +92,10 @@ static int qcom_ec_read(struct qcom_ec *ec, u8 cmd, u8 resp_len, u8 *resp)
>  		return ret;
>  	else if (ret == 0 || ret == 0xff)
>  		return -EOPNOTSUPP;
> +	else if (ret != resp_len)
> +		return -EIO;
>  
> -	if (resp[0] >= resp_len)
> +	if (resp[0] != resp_len - 1)
>  		return -EINVAL;
>  
>  	return 0;

Thanks for catching this — nice find.

This is independently fixed in an in-flight series that reworks
qcom_ec_read() to use raw i2c_transfer() instead of
i2c_smbus_read_i2c_block_data(), removing the partial-read case
entirely, and it already has the same resp[0] != resp_len - 1 check.
That series just hasn't landed yet, so your report stands on its own —
happy to add a Reported-by: Linmao Li <lilinmao@kylinos.cn> tag on that
commit when it's re-posted, if that works for you.

Series:
https://lore.kernel.org/r/20260728-ec_add_more_commands-v1-0-771abd65ee1a@oss.qualcomm.com

> 
> base-commit: c5e32e86ca02b003f86e095d379b38148999293d

-- 
Best Regards,
Anvesh


  parent reply	other threads:[~2026-07-29 10:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 11:19 Linmao Li
2026-07-28 11:25 ` Bryan O'Donoghue
2026-07-29 10:08 ` Anvesh Jain P [this message]
2026-07-29 10:23   ` Bryan O'Donoghue
2026-07-29 10:49     ` Anvesh Jain P
2026-08-03 19:12 ` Ilpo Järvinen

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=d1a6474c-68c1-42f1-8d2d-ad5acdd25fd6@oss.qualcomm.com \
    --to=anvesh.p@oss.qualcomm.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=lilinmao@kylinos.cn \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maccraft123mc@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sibi.sankar@oss.qualcomm.com \
    /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®