Skip to content

Commit

Permalink
USB: rio500: fix memory leak in close after disconnect
Browse files Browse the repository at this point in the history
commit e0feb73 upstream.

If a disconnected device is closed, rio_close() must free
the buffers.

Signed-off-by: Oliver Neukum <[email protected]>
Cc: stable <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Change-Id: I79fdd310375418de3302796b4cefa2a908edf572
  • Loading branch information
oneukum authored and Zile995 committed Jun 18, 2019
1 parent e540e19 commit 427346b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions drivers/usb/misc/rio500.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 427346b

Please sign in to comment.