diff options
author | Oliver Neukum <oneukum@suse.com> | 2019-05-09 05:30:59 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-21 04:11:10 -0400 |
commit | e0feb73428b69322dd5caae90b0207de369b5575 (patch) | |
tree | 98591f5bb0f97089148269b2b199013f5056a6e3 | |
parent | 3864d33943b4a76c6e64616280e98d2410b1190f (diff) |
USB: rio500: fix memory leak in close after disconnect
If a disconnected device is closed, rio_close() must free
the buffers.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/misc/rio500.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 1d397d93d127..a32d61a79ab8 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c | |||
@@ -86,9 +86,22 @@ static int close_rio(struct inode *inode, struct file *file) | |||
86 | { | 86 | { |
87 | struct rio_usb_data *rio = &rio_instance; | 87 | struct rio_usb_data *rio = &rio_instance; |
88 | 88 | ||
89 | rio->isopen = 0; | 89 | /* against disconnect() */ |
90 | mutex_lock(&rio500_mutex); | ||
91 | mutex_lock(&(rio->lock)); | ||
90 | 92 | ||
91 | dev_info(&rio->rio_dev->dev, "Rio closed.\n"); | 93 | rio->isopen = 0; |
94 | if (!rio->present) { | ||
95 | /* cleanup has been delayed */ | ||
96 | kfree(rio->ibuf); | ||
97 | kfree(rio->obuf); | ||
98 | rio->ibuf = NULL; | ||
99 | rio->obuf = NULL; | ||
100 | } else { | ||
101 | dev_info(&rio->rio_dev->dev, "Rio closed.\n"); | ||
102 | } | ||
103 | mutex_unlock(&(rio->lock)); | ||
104 | mutex_unlock(&rio500_mutex); | ||
92 | return 0; | 105 | return 0; |
93 | } | 106 | } |
94 | 107 | ||