Skip to contentSkip to conversation

driver: uio: fix possible memory leak in uio_open

PATCH Superseded liujian 3 participants 4 messages Jan 3, 2019 – Jan 8, 2019 Userspace I/O (UIO)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

liujian

author
#0 lore raw

PATCH v3 1/1 driver: uio: fix possible memory leak in uio_open

Fixes 57c5f4df0a5a ("uio: fix crash after the device is unregistered")

---
v1->v2:
rename the "err_infoopen" to "err_idev_info"
v2->3:
put the extra info after the "--"

 drivers/uio/uio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/uio/uio.c +4 -3
index 5c10fc7..aab3520 100644
@@ -496,18 +496,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:
Signature · 1 line
2.7.4
#1 lore raw
Quoted 7 lines · liujian
Fixes 57c5f4df0a5a ("uio: fix crash after the device is unregistered")

---
v1->v2:
rename the "err_infoopen" to "err_idev_info"
v2->3:
put the extra info after the "--"

Looks good to me.

Thanks.
BRs

Quoted 30 lines
  drivers/uio/uio.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/uio/uio.c +4 -3
index 5c10fc7..aab3520 100644
@@ -496,18 +496,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:
maintainer
#2 lore raw
In reply to liujian
Quoted 2 lines · liujian
Fixes 57c5f4df0a5a ("uio: fix crash after the device is unregistered")

I can not take patches without any changelog text at all :(

Also, is "liujian" your full name? We need a real and full name for a signed-off-by line.

thanks,

greg k-h

#3 lore raw
Quoted 10 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Tuesday, January 08, 2019 12:14 AM
To: liujian (CE) <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v3] driver: uio: fix possible memory leak in uio_open

Quoted 7 lines
Quoted 3 lines · liujian
Fixes 57c5f4df0a5a ("uio: fix crash after the device is

unregistered")

I can not take patches without any changelog text at all :(

I am sorry, I will resend the patch~

Quoted 3 lines

Also, is "liujian" your full name? We need a real and full name for a signed-off-by line.

Yes, but as someone do, I may need change 'liujian' to 'Liu Jian' Thanks

Quoted 3 lines

thanks,

greg k-h