2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-18 18:23:53 +08:00

airo: fix memory leaks

In proc_BSSList_open(), 'file->private_data' is allocated through kzalloc()
and 'data->rbuffer' is allocated through kmalloc(). In the following
execution, if an error occurs, they are not deallocated, leading to memory
leaks. To fix this issue, free the allocated memory regions before
returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
Wenwen Wang 2019-08-15 22:50:02 -05:00 committed by Kalle Valo
parent 7a2eb7367f
commit 145a32fe57

View File

@ -5441,11 +5441,18 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
Cmd cmd;
Resp rsp;
if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN;
if (ai->flags & FLAG_RADIO_MASK) {
kfree(data->rbuffer);
kfree(file->private_data);
return -ENETDOWN;
}
memset(&cmd, 0, sizeof(cmd));
cmd.cmd=CMD_LISTBSS;
if (down_interruptible(&ai->sem))
if (down_interruptible(&ai->sem)) {
kfree(data->rbuffer);
kfree(file->private_data);
return -ERESTARTSYS;
}
issuecommand(ai, &cmd, &rsp);
up(&ai->sem);
data->readlen = 0;