[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1548196704-352035-1-git-send-email-liujian56@huawei.com>
Date: Wed, 23 Jan 2019 06:38:24 +0800
From: Liu Jian <liujian56@...wei.com>
To: <gregkh@...uxfoundation.org>
CC: <xiubli@...hat.com>, <liujian56@...wei.com>,
<linux-kernel@...r.kernel.org>
Subject: [PATCH v5] driver: uio: fix possible memory leak in uio_open
If 'idev->info' is NULL, we need to free 'listener'
Fixes: 57c5f4df0a5a ("uio: fix crash after the device is unregistered")
Signed-off-by: Liu Jian <liujian56@...wei.com>
---
v1->v2:
rename the "err_infoopen" to "err_idev_info"
v2->3:
put the extra info after the "--"
v3-v4:
add git log
v4-v5:
correct git log
drivers/uio/uio.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 1313422..b4ae2d9 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -491,18 +491,19 @@ static int uio_open(struct inode *inode, struct file *filep)
if (!idev->info) {
mutex_unlock(&idev->info_lock);
ret = -EINVAL;
- goto err_alloc_listener;
+ goto err_idev_info;
}
if (idev->info && idev->info->open)
ret = idev->info->open(idev->info, inode);
mutex_unlock(&idev->info_lock);
if (ret)
- goto err_infoopen;
+ goto err_idev_info;
return 0;
-err_infoopen:
+err_idev_info:
+ filep->private_data = NULL;
kfree(listener);
err_alloc_listener:
--
2.7.4
Powered by blists - more mailing lists