Skip to content

Commit e7d796f

Browse files
mrhpearsonjwrdegoede
authored andcommitted
platform/x86: think-lmi: Fix memory leaks when parsing ThinkStation WMI strings
My previous commit introduced a memory leak where the item allocated from tlmi_setting was not freed. This commit also renames it to avoid confusion with the similarly name variable in the same function. Fixes: 8a02d70 ("platform/x86: think-lmi: Add possible_values for ThinkStation") Reported-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr> Link: https://lore.kernel.org/lkml/df26ff45-8933-f2b3-25f4-6ee51ccda7d8@gmx.de/T/ Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca> Link: https://lore.kernel.org/r/20230403013120.2105-1-mpearson-lenovo@squebb.ca Tested-by: Mario Limonciello <mario.limonciello@amd.com> Tested-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent a3c4c05 commit e7d796f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/platform/x86/think-lmi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,10 +1459,10 @@ static int tlmi_analyze(void)
14591459
* name string.
14601460
* Try and pull that out if it's available.
14611461
*/
1462-
char *item, *optstart, *optend;
1462+
char *optitem, *optstart, *optend;
14631463

1464-
if (!tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID)) {
1465-
optstart = strstr(item, "[Optional:");
1464+
if (!tlmi_setting(setting->index, &optitem, LENOVO_BIOS_SETTING_GUID)) {
1465+
optstart = strstr(optitem, "[Optional:");
14661466
if (optstart) {
14671467
optstart += strlen("[Optional:");
14681468
optend = strstr(optstart, "]");
@@ -1471,6 +1471,7 @@ static int tlmi_analyze(void)
14711471
kstrndup(optstart, optend - optstart,
14721472
GFP_KERNEL);
14731473
}
1474+
kfree(optitem);
14741475
}
14751476
}
14761477
/*

0 commit comments

Comments
 (0)