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

From: Andy Shevchenko
Date: Tue Aug 10 2010 - 08:21:14 EST


On Tue, Aug 10, 2010 at 3:03 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>

> @@ -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,
> + Â Â Â Â Â Â Â ptl_to, tosym, to_p);
Did you ever compile this code?
It looks typo here.

> + Â Â Â Â Â Â Â 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"

--
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/