* [PATCH] mei: Fix error handling in mei_register
@ 2025-11-04 2:01 Ma Ke
2025-11-04 15:25 ` Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ma Ke @ 2025-11-04 2:01 UTC (permalink / raw)
To: alexander.usyskin, arnd, gregkh; +Cc: linux-kernel, akpm, Ma Ke, stable
mei_register() fails to release the device reference in error paths
after device_initialize(). During normal device registration, the
reference is properly handled through mei_deregister() which calls
device_destroy(). However, in error handling paths (such as cdev_alloc
failure, cdev_add failure, etc.), missing put_device() calls cause
reference count leaks, preventing the device's release function
(mei_device_release) from being called and resulting in memory leaks
of mei_device.
Found by code review.
Cc: stable@vger.kernel.org
Fixes: 7704e6be4ed2 ("mei: hook mei_device on class device")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
drivers/misc/mei/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 86a73684a373..6f26d5160788 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -1307,6 +1307,7 @@ int mei_register(struct mei_device *dev, struct device *parent)
err_del_cdev:
cdev_del(dev->cdev);
err:
+ put_device(&dev->dev);
mei_minor_free(minor);
return ret;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] mei: Fix error handling in mei_register
2025-11-04 2:01 [PATCH] mei: Fix error handling in mei_register Ma Ke
@ 2025-11-04 15:25 ` Markus Elfring
2025-11-04 15:30 ` Markus Elfring
2025-11-10 11:31 ` Usyskin, Alexander
2 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2025-11-04 15:25 UTC (permalink / raw)
To: make24; +Cc: akpm, alexander.usyskin, arnd, gregkh, linux-kernel, stable
> mei_register() fails to release the device reference in error paths
…
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mei: Fix error handling in mei_register
2025-11-04 2:01 [PATCH] mei: Fix error handling in mei_register Ma Ke
2025-11-04 15:25 ` Markus Elfring
@ 2025-11-04 15:30 ` Markus Elfring
2025-11-04 22:23 ` Greg Kroah-Hartman
2025-11-10 11:31 ` Usyskin, Alexander
2 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2025-11-04 15:30 UTC (permalink / raw)
To: make24
Cc: stable, LKML, Alexander Usyskin, Andrew Morton, Arnd Bergmann,
Greg Kroah-Hartman
> mei_register() fails to release the device reference in error paths
…
Would it be helpful to append parentheses also to the function name
in the summary phrase?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mei: Fix error handling in mei_register
2025-11-04 15:30 ` Markus Elfring
@ 2025-11-04 22:23 ` Greg Kroah-Hartman
0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2025-11-04 22:23 UTC (permalink / raw)
To: Markus Elfring
Cc: make24, stable, LKML, Alexander Usyskin, Andrew Morton,
Arnd Bergmann
On Tue, Nov 04, 2025 at 04:30:08PM +0100, Markus Elfring wrote:
> > mei_register() fails to release the device reference in error paths
> …
>
> Would it be helpful to append parentheses also to the function name
> in the summary phrase?
>
> Regards,
> Markus
Hi,
This is the semi-friendly patch-bot of Greg Kroah-Hartman.
Markus, you seem to have sent a nonsensical or otherwise pointless
review comment to a patch submission on a Linux kernel developer mailing
list. I strongly suggest that you not do this anymore. Please do not
bother developers who are actively working to produce patches and
features with comments that, in the end, are a waste of time.
Patch submitter, please ignore Markus's suggestion; you do not need to
follow it at all. The person/bot/AI that sent it is being ignored by
almost all Linux kernel maintainers for having a persistent pattern of
behavior of producing distracting and pointless commentary, and
inability to adapt to feedback. Please feel free to also ignore emails
from them.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] mei: Fix error handling in mei_register
2025-11-04 2:01 [PATCH] mei: Fix error handling in mei_register Ma Ke
2025-11-04 15:25 ` Markus Elfring
2025-11-04 15:30 ` Markus Elfring
@ 2025-11-10 11:31 ` Usyskin, Alexander
2 siblings, 0 replies; 5+ messages in thread
From: Usyskin, Alexander @ 2025-11-10 11:31 UTC (permalink / raw)
To: Ma Ke, arnd@arndb.de, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
stable@vger.kernel.org
> Subject: [PATCH] mei: Fix error handling in mei_register
>
> mei_register() fails to release the device reference in error paths
> after device_initialize(). During normal device registration, the
> reference is properly handled through mei_deregister() which calls
> device_destroy(). However, in error handling paths (such as cdev_alloc
> failure, cdev_add failure, etc.), missing put_device() calls cause
> reference count leaks, preventing the device's release function
> (mei_device_release) from being called and resulting in memory leaks
> of mei_device.
>
> Found by code review.
>
Nice catch.
Acked-by: Alexander Usyskin <alexander.usyskin@intel.com>
> Cc: stable@vger.kernel.org
> Fixes: 7704e6be4ed2 ("mei: hook mei_device on class device")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> drivers/misc/mei/main.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
> index 86a73684a373..6f26d5160788 100644
> --- a/drivers/misc/mei/main.c
> +++ b/drivers/misc/mei/main.c
> @@ -1307,6 +1307,7 @@ int mei_register(struct mei_device *dev, struct
> device *parent)
> err_del_cdev:
> cdev_del(dev->cdev);
> err:
> + put_device(&dev->dev);
> mei_minor_free(minor);
> return ret;
> }
> --
> 2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-10 11:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-04 2:01 [PATCH] mei: Fix error handling in mei_register Ma Ke
2025-11-04 15:25 ` Markus Elfring
2025-11-04 15:30 ` Markus Elfring
2025-11-04 22:23 ` Greg Kroah-Hartman
2025-11-10 11:31 ` Usyskin, Alexander
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox