Message ID | 20230403013120.2105-1-mpearson-lenovo@squebb.ca (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
Series | [v2,1/2] platform/x86: think-lmi: Fix memory leaks when parsing ThinkStation WMI strings | expand |
Hi, On 4/3/23 03:31, Mark Pearson wrote: > 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: 8a02d70679fc ("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> > --- > This patch series builds on top of the proposed patch from Armin Wolf > "platform/x86: think-lmi: Fix memory leak when showing current settings" > Changes in v2: None, but rebased series because of issues with second > patch. Thank you for your patch series, I've applied this series to my fixes branch: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=fixes Note it will show up in my fixes branch once I've pushed my local branch there, which might take a while. I will include this series in my next fixes pull-req to Linus for the current kernel development cycle. Regards, Hans > > drivers/platform/x86/think-lmi.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c > index 6034df6d577d..87f832142d8d 100644 > --- a/drivers/platform/x86/think-lmi.c > +++ b/drivers/platform/x86/think-lmi.c > @@ -1459,10 +1459,10 @@ static int tlmi_analyze(void) > * name string. > * Try and pull that out if it's available. > */ > - char *item, *optstart, *optend; > + char *optitem, *optstart, *optend; > > - if (!tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID)) { > - optstart = strstr(item, "[Optional:"); > + if (!tlmi_setting(setting->index, &optitem, LENOVO_BIOS_SETTING_GUID)) { > + optstart = strstr(optitem, "[Optional:"); > if (optstart) { > optstart += strlen("[Optional:"); > optend = strstr(optstart, "]"); > @@ -1471,6 +1471,7 @@ static int tlmi_analyze(void) > kstrndup(optstart, optend - optstart, > GFP_KERNEL); > } > + kfree(optitem); > } > } > /*
diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 6034df6d577d..87f832142d8d 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -1459,10 +1459,10 @@ static int tlmi_analyze(void) * name string. * Try and pull that out if it's available. */ - char *item, *optstart, *optend; + char *optitem, *optstart, *optend; - if (!tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID)) { - optstart = strstr(item, "[Optional:"); + if (!tlmi_setting(setting->index, &optitem, LENOVO_BIOS_SETTING_GUID)) { + optstart = strstr(optitem, "[Optional:"); if (optstart) { optstart += strlen("[Optional:"); optend = strstr(optstart, "]"); @@ -1471,6 +1471,7 @@ static int tlmi_analyze(void) kstrndup(optstart, optend - optstart, GFP_KERNEL); } + kfree(optitem); } } /*
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: 8a02d70679fc ("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> --- This patch series builds on top of the proposed patch from Armin Wolf "platform/x86: think-lmi: Fix memory leak when showing current settings" Changes in v2: None, but rebased series because of issues with second patch. drivers/platform/x86/think-lmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)