login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
August
»
10
Re: [PATCHv4] modpost: fixed resource leak in report_sec_mismatch()
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [
author
]
[view in full thread]
From: Andy Shevchenko
Subject:
Re: [PATCHv4] modpost: fixed resource leak in report_sec_mismatch()
Date: Tuesday, August 10, 2010 - 6:43 am
On Tue, Aug 10, 2010 at 4:09 PM, Alexey Fomenko <ext-alexey.fomenko@nokia.com> wrote:
quoted text
> From: Alexey Fomenko <ext-alexey.fomenko@nokia.com> > > sec2annotation() returns malloc'ed buffer directly to printf as an > argument. Patch lets free this buffer after printing. Preventing ops > while freeing the buffer by changing return const str to return > strdup empty line. > Signed-off-by: Alexey Fomenko <ext-alexey.fomenko@nokia.com> > --- > scripts/mod/modpost.c | 62 > ++++++++++++++++++++++++++++++++---------------- > 1 files changed, 43 insertions(+), 19 deletions(-) > > diff -ur linux-2.6.35/scripts/mod/modpost.c > linux-2.6.35_b/scripts/mod/modpost.c > --- linux-2.6.35/scripts/mod/modpost.c 2010-08-10 12:11:03.854528620 +0300 > +++ linux-2.6.35_b/scripts/mod/modpost.c 2010-08-10 14:45:00.294529178 +0300 > @@ -1165,9 +1165,9 @@ > strcat(p, "data "); > else > strcat(p, " "); > - return r; /* we leak her but we do not care */ > + return r; > } else { > - return ""; > + return strdup(""); > } > } > > @@ -1195,6 +1195,8 @@ > { > const char *from, *from_p; > const char *to, *to_p; > + char *prl_from; > + char *prl_to; > > > switch (from_is_func) { > @@ -1219,16 +1221,21 @@ > > switch (mismatch->mismatch) { > case TEXT_TO_ANY_INIT: > + prl_from = sec2annotation(fromsec); > + prl_to = sec2annotation(tosec); > fprintf(stderr, > "The function %s%s() references\n" > "the %s %s%s%s.\n" > "This is often because %s lacks a %s\n" > "annotation or the annotation of %s is wrong.\n", > - sec2annotation(fromsec), fromsym, > - to, sec2annotation(tosec), tosym, to_p, > - fromsym, sec2annotation(tosec), tosym); > + prl_from, fromsym, > + to, prl_to, tosym, to_p, > + fromsym, prl_to, tosym); > + free(prl_from); > + free(prl_to); > break; > case DATA_TO_ANY_INIT: { > + prl_to = sec2annotation(tosec); > const char *const *s = mismatch->symbol_white_list; > fprintf(stderr, > "The variable %s references\n" > @@ -1236,20 +1243,24 @@ > "If the reference is valid then annotate the\n" > "variable with __init* or __refdata (see linux/init.h) " > "or name the variable:\n", > - fromsym, to, sec2annotation(tosec), tosym, to_p); > + fromsym, to, prl_to, tosym, to_p); > while (*s) > fprintf(stderr, "%s, ", *s++); > fprintf(stderr, "\n"); > + free(prl_to); > break; > } > case TEXT_TO_ANY_EXIT: > + prl_to = sec2annotation(tosec); > fprintf(stderr, > "The function %s() references a %s in an exit section.\n" > "Often the %s %s%s has valid usage outside the exit section\n" > "and the fix is to remove the %sannotation of %s.\n", > - fromsym, to, to, tosym, to_p, sec2annotation(tosec), tosym); > + fromsym, to, to, tosym, to_p, prl_to, tosym); > + free(prl_to); > break; > case DATA_TO_ANY_EXIT: { > + prl_to = sec2annotation(tosec); > const char *const *s = mismatch->symbol_white_list; > fprintf(stderr, > "The variable %s references\n" > @@ -1257,24 +1268,31 @@ > "If the reference is valid then annotate the\n" > "variable with __exit* (see linux/init.h) or " > "name the variable:\n", > - fromsym, to, sec2annotation(tosec), tosym, to_p); > + fromsym, to, prl_to, tosym, to_p); > while (*s) > fprintf(stderr, "%s, ", *s++); > fprintf(stderr, "\n"); > + free(prl_to); > break; > } > case XXXINIT_TO_SOME_INIT: > case XXXEXIT_TO_SOME_EXIT: > + prl_from = sec2annotation(fromsec); > + prl_to = sec2annotation(tosec); > fprintf(stderr, > "The %s %s%s%s references\n" > "a %s %s%s%s.\n" > "If %s is only used by %s then\n" > "annotate %s with a matching annotation.\n", > - from, sec2annotation(fromsec), fromsym, from_p, > - to, sec2annotation(tosec), tosym, to_p, > + from, prl_from, fromsym, from_p, > + to, prl_to, tosym, to_p, > tosym, fromsym, tosym); > + free(prl_from); > + free(prl_to); > break; > case ANY_INIT_TO_ANY_EXIT: > + prl_from = sec2annotation(fromsec); > + prl_to = sec2annotation(tosec); > fprintf(stderr, > "The %s %s%s%s references\n" > "a %s %s%s%s.\n" > @@ -1283,11 +1301,15 @@ > "uses functionality in the exit path.\n" > "The fix is often to remove the %sannotation of\n" > "%s%s so it may be used outside an exit section.\n", > - from, sec2annotation(fromsec), fromsym, from_p, > - to, sec2annotation(tosec), tosym, to_p, > - sec2annotation(tosec), tosym, to_p); > + from, prl_from, fromsym, from_p, > + to, prl_to, tosym, to_p, > + prl_to, tosym, to_p); > + free(prl_from); > + free(prl_to); > break; > case ANY_EXIT_TO_ANY_INIT: > + prl_from = sec2annotation(fromsec); > + prl_to = sec2annotation(tosec); > fprintf(stderr, > "The %s %s%s%s references\n" > "a %s %s%s%s.\n" > @@ -1296,16 +1318,20 @@ > "uses functionality in the init path.\n" > "The fix is often to remove the %sannotation of\n" > "%s%s so it may be used outside an init section.\n", > - from, sec2annotation(fromsec), fromsym, from_p, > - to, sec2annotation(tosec), tosym, to_p, > - sec2annotation(tosec), tosym, to_p); > + from, prl_from, fromsym, from_p, > + to, prl_to, tosym, to_p, > + prl_to, tosym, to_p); > + free(prl_from); > + free(prl_to); > break; > case EXPORT_TO_INIT_EXIT: > + prl_to = sec2annotation(tosec); > fprintf(stderr, > "The symbol %s is exported and annotated %s\n" > "Fix this by removing the %sannotation of %s " > "or drop the export.\n", > - tosym, sec2annotation(tosec), sec2annotation(tosec), tosym); > + tosym, prl_to, prl_to, tosym); > + free(prl_to); > break; > } > fprintf(stderr, "\n"); > >
Now seems fine to me. Reviewed-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com> -- With Best Regards, Andy Shevchenko --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [
author
]
Messages in current thread:
[PATCHv2] fixed resource leak in scripts/mod/modpost.c
, Alexey Fomenko
, (Thu Aug 5, 5:09 am)
Re: [PATCHv2] fixed resource leak in scripts/mod/modpost.c
, Andy Shevchenko
, (Tue Aug 10, 2:14 am)
[PATCHv3] fixed resource leak in scripts/mod/modpost.c
, Alexey Fomenko
, (Tue Aug 10, 3:52 am)
Re: [PATCHv3] fixed resource leak in scripts/mod/modpost.c
, Andy Shevchenko
, (Tue Aug 10, 4:35 am)
[PATCHv4] fixed resource leak in scripts/mod/modpost.c
, Alexey Fomenko
, (Tue Aug 10, 5:03 am)
Re: [PATCHv4] fixed resource leak in scripts/mod/modpost.c
, Andy Shevchenko
, (Tue Aug 10, 5:21 am)
Re: [PATCHv4] fixed resource leak in scripts/mod/modpost.c
, Alexey Fomenko
, (Tue Aug 10, 5:40 am)
Re: [PATCHv4] modpost: fixed resource leak in report_sec_m ...
, Andy Shevchenko
, (Tue Aug 10, 6:43 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Michael Trimarchi
Re: [PATCH] VFS: make file->f_pos access atomic on 32bit arch
Miklos Szeredi
[patch 14/15] vfs: more path_permission() conversions
Serge E. Hallyn
Re: [RFC v5][PATCH 7/8] Infrastructure for shared objects
Bernd Schmidt
Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3
Takashi Iwai
[PATCH 2/2] input: Add LED support to Synaptics device
git
:
Junio C Hamano
Re: mingw, windows, crlf/lf, and git
Eyvind Bernhardsen
Re: Where has "git ls-remote" reference pattern matching gone?
Shawn O. Pearce
Re: Switching from CVS to GIT
Todd Zullinger
Re: [PATCH 2/2] send-email: rfc2047-quote subject lines with non-ascii characters
Santi Béjar
Re: How to use git-fmt-merge-msg?
linux-netdev
:
Ramkrishna Vepa
[net-2.6 PATCH 1/10] Neterion: New driver: Driver help file
Mark Anthony
invitation / inquiry
Ingo Molnar
Re: [PATCH 08/16] dma-debug: add core checking functions
David Miller
Re: [PATCH 1/3] f_phonet: dev_kfree_skb instead of dev_kfree_skb_any in TX callback
Sascha Hauer
[PATCH 03/12] fec: do not typedef struct types
git-commits-head
:
Linux Kernel Mailing List
amba: struct device - replace bus_id with dev_name(), dev_set_name()
Linux Kernel Mailing List
MIPS: Yosemite: Convert SMP startup lock to arch spinlock.
Linux Kernel Mailing List
ARM: S5PC100: IRQ and timer
Linux Kernel Mailing List
davinci: edma: clear interrupt status for interrupt enabled channels only
Linux Kernel Mailing List
x86, mm, kprobes: fault.c, simplify notify_page_fault()
openbsd-misc
:
Daniel A. Ramaley
Re: [semi-OT] Can anyone recommend an OpenBSD-compatible colour laser printer?
Matthias Kilian
Re: can't get vesa @ 1280x800 or nv
Tobias Ulmer
Re: Problem after upgrade 4.5 to 4.6: ERR M
Philip Guenther
Re: SIGCHLD and libpthread.so
J.C. Roberts
Re: [semi-OT] Can anyone recommend an OpenBSD-compatible colour laser printer?
Colocation donated by:
Syndicate