From: "Mark Pearson" <mpearson-lenovo@squebb.ca>
To: "Guenter Roeck" <linux@roeck-us.net>, Kean <rh_king@163.com>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] hwmon: lenovo-ec-sensors: Fix EC signature check logic in probe
Date: Wed, 13 May 2026 22:40:55 -0400 [thread overview]
Message-ID: <18f59754-c7cd-4fe5-b670-b7e7125b5679@app.fastmail.com> (raw)
In-Reply-To: <80804838-5526-4096-b0ee-d6b46bbe0ecb@roeck-us.net>
Hi Guenter,
On Wed, May 13, 2026, at 9:37 PM, Guenter Roeck wrote:
> On 5/13/26 18:14, Kean wrote:
>> The probe function reads a 4-byte signature ("MCHP") from the EC to
>> verify it is a Microchip EC before binding the driver. The condition
>> uses && (AND) to check if each byte differs from the expected value:
>>
>> if ((byte0 != 'M') && (byte1 != 'C') && (byte2 != 'H') && (byte3 != 'P'))
>>
>> This rejects the device only if ALL four bytes are wrong simultaneously.
>> A partially matching signature (e.g. "MXXX") would pass the check and
>> cause the driver to bind to a non-Microchip EC, as long as at least one
>> byte matches the expected value.
>>
>> Change && to || so the driver is rejected when ANY byte does not match
>> the expected "MCHP" signature.
>>
>> Signed-off-by: Kean <rh_king@163.com>
>>
>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>
> As with the other patches: How do I know that this review really happened ?
I confirm I did it.
For the series:
Reviewed-by: Mark Pearson <mpearson@lenovo@squebb.ca>
Mark
>
> Guenter
>
>> ---
>> drivers/hwmon/lenovo-ec-sensors.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/hwmon/lenovo-ec-sensors.c b/drivers/hwmon/lenovo-ec-sensors.c
>> index 8681bbf6665b..a32b1f2c6a3a 100644
>> --- a/drivers/hwmon/lenovo-ec-sensors.c
>> +++ b/drivers/hwmon/lenovo-ec-sensors.c
>> @@ -537,9 +537,9 @@ static int lenovo_ec_probe(struct platform_device *pdev)
>> outw_p(MCHP_SING_IDX, MCHP_EMI0_EC_ADDRESS);
>> mutex_unlock(&ec_data->mec_mutex);
>>
>> - if ((inb_p(MCHP_EMI0_EC_DATA_BYTE0) != 'M') &&
>> - (inb_p(MCHP_EMI0_EC_DATA_BYTE1) != 'C') &&
>> - (inb_p(MCHP_EMI0_EC_DATA_BYTE2) != 'H') &&
>> + if ((inb_p(MCHP_EMI0_EC_DATA_BYTE0) != 'M') ||
>> + (inb_p(MCHP_EMI0_EC_DATA_BYTE1) != 'C') ||
>> + (inb_p(MCHP_EMI0_EC_DATA_BYTE2) != 'H') ||
>> (inb_p(MCHP_EMI0_EC_DATA_BYTE3) != 'P')) {
>> release_region(IO_REGION_START, IO_REGION_LENGTH);
>> return -ENODEV;
next prev parent reply other threads:[~2026-05-14 2:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 1:14 [PATCH 0/3] hwmon: lenovo-ec-sensors: Probe error handling fixes Kean
2026-05-14 1:14 ` [PATCH 1/3] hwmon: lenovo-ec-sensors: Fix EC signature check logic in probe Kean
2026-05-14 1:37 ` Guenter Roeck
2026-05-14 2:40 ` Mark Pearson [this message]
2026-05-14 1:14 ` [PATCH 2/3] hwmon: lenovo-ec-sensors: Fix NULL pointer dereference when DMI match fails Kean
2026-05-14 1:29 ` Guenter Roeck
2026-05-14 3:25 ` Guenter Roeck
2026-05-14 11:57 ` sashiko-bot
2026-05-14 1:14 ` [PATCH 3/3] hwmon: lenovo-ec-sensors: Use devm_request_region for automatic cleanup Kean
2026-05-14 1:36 ` Guenter Roeck
2026-05-14 2:39 ` Mark Pearson
2026-05-14 3:24 ` Guenter Roeck
2026-05-14 12:19 ` sashiko-bot
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=18f59754-c7cd-4fe5-b670-b7e7125b5679@app.fastmail.com \
--to=mpearson-lenovo@squebb.ca \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=rh_king@163.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