From: Guenter Roeck <linux@roeck-us.net>
To: Mark Pearson <mpearson-lenovo@squebb.ca>, Kean <rh_king@163.com>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] hwmon: lenovo-ec-sensors: Use devm_request_region for automatic cleanup
Date: Wed, 13 May 2026 20:24:20 -0700 [thread overview]
Message-ID: <40e8a830-4e2e-4627-8745-a1f05d8d31ba@roeck-us.net> (raw)
In-Reply-To: <1d6239f3-6383-4262-97b5-01c289dc5e7b@app.fastmail.com>
On 5/13/26 19:39, Mark Pearson wrote:
> Hi Guenter,
>
> On Wed, May 13, 2026, at 9:36 PM, Guenter Roeck wrote:
>> On 5/13/26 18:14, Kean wrote:
>>> Replace manual request_region()/release_region() with
>>> devm_request_region(). This lets the device-managed framework
>>> handle I/O region lifetime automatically and fixes:
>>>
>>> - A double release_region() when probe fails after acquiring the
>>> I/O region: the probe error path releases it, and then
>>> lenovo_ec_init() releases it again on the same error path.
>>>
>>> - A release-after-free in lenovo_ec_exit() where release_region()
>>> was called after platform_device_unregister(), which has already
>>> released the I/O region via the platform device removal path.
>>>
>>> - Missing release_region() in lenovo_ec_probe() on the DMI match
>>> failure path, which leaked the I/O region.
>>>
>>> Remove all manual release_region() calls that are now handled
>>> automatically by the devm framework.
>>>
>>> Signed-off-by: Kean <rh_king@163.com>
>>>
>> Why this empty line ?
>>
>>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>
>> How do I know that this review really happened ?
>
> The reviewed by's are correct - I can confirm I did review these patches before Kean pushed them upstream. We did some internal review first to discuss the issues he identified.
>
> We sometimes take this approach with the platform/x86 patches. We can do it separately next time if preferred here.
>
Kean <rh_king@163.com> is not a full name, has no patches in the upstream
kernel or in linux-next, and otherwise seems to be a complete unknown.
How do you expect me to know that this isn't all made up by some AI ?
Anyway, when you do that, please at least ask people to run checkpatch.
I really don't want to have to deal with trivial issues such as
ERROR: trailing whitespace
#135: FILE: drivers/hwmon/lenovo-ec-sensors.c:611:
+^Iif (IS_ERR(lenovo_ec_sensors_platform_device)) $
in this patch and the first patch of the series.
Guenter
> Mark
>
>>
>>> ---
>>> drivers/hwmon/lenovo-ec-sensors.c | 13 +++++--------
>>> 1 file changed, 5 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/hwmon/lenovo-ec-sensors.c b/drivers/hwmon/lenovo-ec-sensors.c
>>> index b0f2a04ce679..ea74bddbad5a 100644
>>> --- a/drivers/hwmon/lenovo-ec-sensors.c
>>> +++ b/drivers/hwmon/lenovo-ec-sensors.c
>>> @@ -519,8 +519,8 @@ static int lenovo_ec_probe(struct platform_device *pdev)
>>> if (!ec_data)
>>> return -ENOMEM;
>>>
>>> - if (!request_region(IO_REGION_START, IO_REGION_LENGTH, "LNV-WKS")) {
>>> - pr_err(":request fail\n");
>>> + if (!devm_request_region(dev, IO_REGION_START, IO_REGION_LENGTH, "LNV-WKS")) {
>>> + dev_err(dev, "Failed to request I/O region.\n");
>>> return -EIO;
>>> }
>>>
>>> @@ -541,7 +541,6 @@ static int lenovo_ec_probe(struct platform_device *pdev)
>>> (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;
>>> }
>>>
>>> @@ -579,7 +578,8 @@ static int lenovo_ec_probe(struct platform_device *pdev)
>>> lenovo_ec_chip_info.info = lenovo_ec_hwmon_info_p8;
>>> break;
>>> default:
>>> - release_region(IO_REGION_START, IO_REGION_LENGTH);
>>> + dev_err(dev, "Unsupported platform type %ld\n",
>>> + (long)dmi_id->driver_data);
>>
>> This is not documented in the commit message and, on top of that, pointless.
>> It isn't even noise, it is just pointless (the default case can not be reached).
>>
>>> return -ENODEV;
>>> }
>>>
>>> @@ -608,10 +608,8 @@ static int __init lenovo_ec_init(void)
>>> platform_create_bundle(&lenovo_ec_sensors_platform_driver,
>>> lenovo_ec_probe, NULL, 0, NULL, 0);
>>>
>>> - if (IS_ERR(lenovo_ec_sensors_platform_device)) {
>>> - release_region(IO_REGION_START, IO_REGION_LENGTH);
>>> + if (IS_ERR(lenovo_ec_sensors_platform_device))
>>> return PTR_ERR(lenovo_ec_sensors_platform_device);
>>> - }
>>>
>>> return 0;
>>> }
>>> @@ -619,7 +617,6 @@ module_init(lenovo_ec_init);
>>>
>>> static void __exit lenovo_ec_exit(void)
>>> {
>>> - release_region(IO_REGION_START, IO_REGION_LENGTH);
>>> platform_device_unregister(lenovo_ec_sensors_platform_device);
>>> platform_driver_unregister(&lenovo_ec_sensors_platform_driver);
>>> }
>
next prev parent reply other threads:[~2026-05-14 3:24 UTC|newest]
Thread overview: 16+ 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
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-15 8:10 ` Kean
2026-05-15 8:48 ` Guenter Roeck
2026-05-15 8:30 ` Kean
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 [this message]
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=40e8a830-4e2e-4627-8745-a1f05d8d31ba@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpearson-lenovo@squebb.ca \
--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