Re: [PATCHv3] fixed resource leak in scripts/mod/modpost.c

From: Andy Shevchenko
Date: Tue Aug 10 2010 - 07:36:05 EST


On Tue, Aug 10, 2010 at 1:52 PM, Alexey Fomenko
<ext-alexey.fomenko@xxxxxxxxx> wrote:
> From: Alexey Fomenko <ext-alexey.fomenko@xxxxxxxxx>
>
> 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@xxxxxxxxx>
> ---
> Âscripts/mod/modpost.c | Â 58 ++++++++++++++++++++++++++++++++++++------------
> Â1 files changed, 42 insertions(+), 16 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 12:11:25.174529109 +0300
> @@ -1165,9 +1165,9 @@
> Â Â Â Â Â Â Â Â Â Â Â Âstrcat(p, "data ");
> Â Â Â Â Â Â Â Âelse
> Â Â Â Â Â Â Â Â Â Â Â Âstrcat(p, " ");
> - Â Â Â Â Â Â Â return r; /* we leak her but we do not care */
> + Â Â Â Â Â Â Â return r;
Here is the extra tail whitespace.

> @@ -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,
> + Â Â Â Â Â Â Â from, prl_from, fromsym, from_p,
> + Â Â Â Â Â Â Â to, prl_to, tosym, to_p,
> Â Â Â Â Â Â Â Âsec2annotation(tosec), tosym, to_p);
^^^^^^^^^^^^^^^^^^^^^^ missed change


Acked-by: Andy Shevchenko <ext-andriy.shevchenko@xxxxxxxxx>
(after fixing above issues)

--
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/