mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 16:37:50 +00:00
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>
This commit is contained in:
parent
859c57f606
commit
dfac77baa2
1 changed files with 5 additions and 1 deletions
|
@ -1908,8 +1908,12 @@ static void c2h_wk_callback(struct work_struct *work)
|
|||
c2h_evt = kmalloc(16, GFP_KERNEL);
|
||||
if (c2h_evt) {
|
||||
/* This C2H event is not read, read & clear now */
|
||||
if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS)
|
||||
if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) {
|
||||
kfree(c2h_evt);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue