mei: Fix error handling in mei_register
Subsystems (3)
PATCH 1/1 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.
--- drivers/misc/mei/main.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/mei/main.c +1 -0
@@ -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; }
Signature · 1 line
2.17.1
Quoted 1 line
mei_register()fails to release the device reference in error paths
…
Quoted 1 line
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
Greg Kroah-Hartman
maintainerQuoted 8 lines · Markus Elfring
Quoted 1 line
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
Quoted 11 lines
Subject: [PATCH] mei: Fix error handling in
mei_register
mei_register()fails to release the device reference in error paths afterdevice_initialize(). During normal device registration, the reference is properly handled throughmei_deregister()which callsdevice_destroy(). However, in error handling paths (such ascdev_allocfailure,cdev_addfailure, etc.), missingput_device()calls cause reference count leaks, preventing the device's release function (mei_device_release) from being called and resulting in memory leaks ofmei_device.
Quoted 2 lines
Found by code review.
Nice catch.
Quoted 22 lines
Fixes 7704e6be4ed2 ("mei: hook mei_device on class device")Signed-off-by Ma Ke <[email protected]>--- drivers/misc/mei/main.c | 1 + 1 file changed, 1 insertion(+)drivers/misc/mei/main.c +1
-0@@ -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