Re: [PATCH] tty: vt: Check for NULL pointer after calling kzalloc

From: Greg KH
Date: Fri Jan 21 2022 - 02:31:57 EST


On Fri, Jan 21, 2022 at 02:53:20PM +0800, Jiasheng Jiang wrote:
> As the potential failure of the allocation, the kzalloc() will return
> NULL pointer.
> Therefore, it should be better to check it in order to avoid the
> dereference of the NULL pointer.
> When it fails, we should free all the allocated memory and return error
> number.
> To make the code more clear, I use the 'err_free', like how
> vc_allocate() deals with the allocation failure.
>
> Fixes: a5f4f52e8211 ("vt: use kzalloc() instead of the bootmem allocator")
> Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
> ---
> drivers/tty/vt/vt.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)

Please note that your patches are being ignored by my email systems (I
saw this because Jiri responded to it.) I recommend at this point in
time that all other kernel subsystem maintainers also ignore them until
you get some more experience and provide changes that work correctly and
are actually tested.

good luck,

greg k-h