Skip to contentSkip to conversation

platform/x86: think-lmi: Free system certificate signatures

PATCH In review Thorsten Blum 3 participants 3 messages Aug 10 – Aug 18

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: think-lmi: Free system certificate signatures

Multi-certificate support also allows the system authentication object to store ->signature and ->save_signature, which leak when the driver is removed. Free the signatures to avoid leaking memory.

Fixes 5dcb5ef12590 ("platform/x86: think-lmi: Multi-certificate support")
---
 drivers/platform/x86/lenovo/think-lmi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/lenovo/think-lmi.c +4 -0
index e215e86e3db7..e3e683bf3469 100644
@@ -1456,6 +1456,10 @@ static void tlmi_release_attr(void)
 	/* Free up any saved signatures */
 	kfree(tlmi_priv.pwd_admin->signature);
 	kfree(tlmi_priv.pwd_admin->save_signature);
+	if (tlmi_priv.pwd_system) {
+		kfree(tlmi_priv.pwd_system->signature);
+		kfree(tlmi_priv.pwd_system->save_signature);
+	}
 
 	/* Authentication structures */
 	list_for_each_entry_safe(pos, n, &tlmi_priv.authentication_kset->list, entry)
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Thorsten Blum

Multi-certificate support also allows the system authentication object to store ->signature and ->save_signature, which leak when the driver is removed. Free the signatures to avoid leaking memory.

Fixes 5dcb5ef12590 ("platform/x86: think-lmi: Multi-certificate support")
---
 drivers/platform/x86/lenovo/think-lmi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/lenovo/think-lmi.c +0 -0
index e215e86e3db7..e3e683bf3469 100644

drivers/platform/x86/lenovo/think-lmi.c static void tlmi_release_attr(void) · line 1465

Quoted 10 lines
drivers/platform/x86/lenovo/think-lmi.c +4 -0
@@ -1456,6 +1456,10 @@ static void tlmi_release_attr(void)
 	/* Free up any saved signatures */
 	kfree(tlmi_priv.pwd_admin->signature);
 	kfree(tlmi_priv.pwd_admin->save_signature);
+	if (tlmi_priv.pwd_system) {
+		kfree(tlmi_priv.pwd_system->signature);
+		kfree(tlmi_priv.pwd_system->save_signature);
+	}
 
 	/* Authentication structures */
 	list_for_each_entry_safe(pos, n, &tlmi_priv.authentication_kset->list, entry)

Ouch, this one is an embarassing miss for me. Thanks for fixing.

Mark

maintainer
#2 lore raw
In reply to Thorsten Blum
Quoted 3 lines · Thorsten Blum

Multi-certificate support also allows the system authentication object to store ->signature and ->save_signature, which leak when the driver is removed. Free the signatures to avoid leaking memory.

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[1/1] platform/x86: think-lmi: Free system certificate signatures

      commit: c81f167393d4379148d603b88b881918e4c66e2e

--
i.