Message ID | 20220531082320.31294-1-ruc_gongyuanjun@163.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/1] tools/symbols: fix memory leak in build_initial_tok_table() | expand |
On 31.05.2022 10:23, Yuanjun Gong wrote: > Free the table[i].sym field of the invalid sym_entry since > it is malloc'ed data. It would help if you said whether this was just an observation from e.g. static code analysis vs you actually having observed the tool running out of memory. This is a short-lived process after all, so "leaking" memory is not normally much of a problem. > --- a/xen/tools/symbols.c > +++ b/xen/tools/symbols.c > @@ -422,6 +422,8 @@ static void build_initial_tok_table(void) > table[pos] = table[i]; > learn_symbol(table[pos].sym, table[pos].len); > pos++; > + } else { > + free(table[i].sym); Indentation is wrong here. Jan
Hi, It seems that this patch has been stale for more than a month, with further actions need to be taken from the author. So I am sending this email as a gentle reminder. Thanks! Kind regards, Henry > -----Original Message----- > Subject: Re: [PATCH 1/1] tools/symbols: fix memory leak in > build_initial_tok_table() > > On 31.05.2022 10:23, Yuanjun Gong wrote: > > Free the table[i].sym field of the invalid sym_entry since > > it is malloc'ed data. > > It would help if you said whether this was just an observation from > e.g. static code analysis vs you actually having observed the tool > running out of memory. This is a short-lived process after all, so > "leaking" memory is not normally much of a problem. > > > --- a/xen/tools/symbols.c > > +++ b/xen/tools/symbols.c > > @@ -422,6 +422,8 @@ static void build_initial_tok_table(void) > > table[pos] = table[i]; > > learn_symbol(table[pos].sym, table[pos].len); > > pos++; > > + } else { > > + free(table[i].sym); > > Indentation is wrong here. > > Jan >
diff --git a/xen/tools/symbols.c b/xen/tools/symbols.c index 710e9785d3..8daa588d2f 100644 --- a/xen/tools/symbols.c +++ b/xen/tools/symbols.c @@ -422,6 +422,8 @@ static void build_initial_tok_table(void) table[pos] = table[i]; learn_symbol(table[pos].sym, table[pos].len); pos++; + } else { + free(table[i].sym); } } table_cnt = pos;
Free the table[i].sym field of the invalid sym_entry since it is malloc'ed data. Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com> --- xen/tools/symbols.c | 2 ++ 1 file changed, 2 insertions(+)