Commit bce6a39f authored by Oliver Neukum's avatar Oliver Neukum Committed by Kleber Sacilotto de Souza

USB: rio500: fix memory leak in close after disconnect

BugLink: https://bugs.launchpad.net/bugs/1832661

commit e0feb734 upstream.

If a disconnected device is closed, rio_close() must free
the buffers.
Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 53938525
......@@ -103,9 +103,22 @@ static int close_rio(struct inode *inode, struct file *file)
{
struct rio_usb_data *rio = &rio_instance;
rio->isopen = 0;
/* against disconnect() */
mutex_lock(&rio500_mutex);
mutex_lock(&(rio->lock));
dev_info(&rio->rio_dev->dev, "Rio closed.\n");
rio->isopen = 0;
if (!rio->present) {
/* cleanup has been delayed */
kfree(rio->ibuf);
kfree(rio->obuf);
rio->ibuf = NULL;
rio->obuf = NULL;
} else {
dev_info(&rio->rio_dev->dev, "Rio closed.\n");
}
mutex_unlock(&(rio->lock));
mutex_unlock(&rio500_mutex);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment