staging: r8188eu: Fix potential memory leak or NULL dereference
authorLarry Finger <Larry.Finger@lwfinger.net>
Fri, 6 Aug 2021 21:32:35 +0000 (16:32 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Aug 2021 10:09:50 +0000 (12:09 +0200)
commitdfac77baa2837a9a4ac66015234854ebccb85bf1
treed438d6d3bcb8ba48fbf9ccbb090859b3bc489be8
parent859c57f606c78cb8b33cabbd22ad1d4ff9f80e4e
staging: r8188eu: Fix potential memory leak or NULL dereference

In routine c2h_wk_callback(() following a kmalloc() call, the
error recovery is flawed. If the kmalloc() returns a pointer
that is not NULL, and the following c2h_evt_read() fails, the
code will leak that buffer. If the kmalloc() fails, a NULL
dereference will occur in the following code.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Link: https://lore.kernel.org/r/20210806213235.22349-1-Larry.Finger@lwfinger.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/core/rtw_cmd.c