lkml.org 
[lkml]   [2017]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/6] kconfig: Don't leak 'option' arguments during parsing
Date
The following strings would leak before this change:

- option env="LEAKED"
- option defconfig_list="LEAKED"

These come in the form of T_WORD tokens and are always allocated on the
heap in zconf.l. Free them.

Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

LEAK SUMMARY:
definitely lost: 344,616 bytes in 14,355 blocks
...

Summary after the fix:

LEAK SUMMARY:
definitely lost: 344,568 bytes in 14,352 blocks
...

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
---
scripts/kconfig/zconf.y | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index a770117..ea6ae16 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -236,8 +236,10 @@ symbol_option_list:
| symbol_option_list T_WORD symbol_option_arg
{
const struct kconf_id *id = kconf_id_lookup($2, strlen($2));
- if (id && id->flags & TF_OPTION)
+ if (id && id->flags & TF_OPTION) {
menu_add_option(id->token, $3);
+ free($3);
+ }
else
zconfprint("warning: ignoring unknown option %s", $2);
free($2);
--
2.7.4
\
 
 \ /
  Last update: 2017-10-08 19:13    [W:0.071 / U:0.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site