Re: [PATCH RFC] serio HIL MLC: don't deref null, don't leak andreturn proper error

From: Dmitry Torokhov
Date: Sat Nov 20 2010 - 16:37:46 EST


On Sat, Nov 20, 2010 at 10:13:45PM +0100, Helge Deller wrote:
> On 11/09/2010 07:35 AM, Dmitry Torokhov wrote:
> >On Sun, Nov 07, 2010 at 08:36:33PM +0100, Jesper Juhl wrote:
> >>Hi,
> >>
> >>While reviewing various users of kernel memory allocation functions I came
> >>across drivers/input/serio/hil_mlc.c::hil_mlc_register() and noticed that
> >> - it calls kzalloc() buf fails to check for a NULL return before use.
> >> - it makes several allocations and if one fails it doesn't free the
> >> previous ones.
> >> - It doesn't return -ENOMEM in the failed memory allocation case (it just
> >> crashes).
> >>This patch corrects all of the above and also reworks the only caller of
> >>this function that I could find
> >>(drivers/input/serio/hp_sdc_mlc.c::hp_sdc_mlc_out()) so that it now checks
> >>the return value of hil_mlc_register() and properly propagate it on
> >>failure and I also restructured the code to remove some labels and goto's
> >>to make it, IMHO nicer to read.
> >>
> >>I have no hardware to test, so please review carefully and let me know if
> >>I've done something completely stupid. Please don't merge this RFC patch
> >>unless at least one or more people who know this code and can actually
> >>test it have ACK'ed it.
> >I think Helge Deller (CCed) used to have access to such hardware...
>
> Yes, and I tested the patch successfully.
>
> Tested-by: Helge Deller <deller@xxxxxx>
> Acked-by: Helge Deller <deller@xxxxxx>
>

Applied, thank you guys.

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