]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
airo: fix memory leaks
authorWenwen Wang <wenwen@cs.uga.edu>
Fri, 16 Aug 2019 03:50:02 +0000 (22:50 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 3 Sep 2019 13:39:33 +0000 (16:39 +0300)
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>
drivers/net/wireless/cisco/airo.c

index 9342ffbe1e8114213868b64dcdfa732ef28481e8..f43c06569ea1c133ac4c921b8a8a639e079ea50f 100644 (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;