linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] driver: uio: fix possible memory leak in uio_open
@ 2019-01-22 22:38 Liu Jian
  2019-01-31 15:36 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Liu Jian @ 2019-01-22 22:38 UTC (permalink / raw)
  To: gregkh; +Cc: xiubli, liujian56, linux-kernel

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@huawei.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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v5] driver: uio: fix possible memory leak in uio_open
  2019-01-22 22:38 [PATCH v5] driver: uio: fix possible memory leak in uio_open Liu Jian
@ 2019-01-31 15:36 ` Greg KH
  2019-02-01  1:45   ` liujian (CE)
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2019-01-31 15:36 UTC (permalink / raw)
  To: Liu Jian; +Cc: xiubli, linux-kernel

On Wed, Jan 23, 2019 at 06:38:24AM +0800, Liu Jian wrote:
> 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@huawei.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
> 

This does not apply to my tree at all :(

Please rebase it against the char-misc-next branch of my char-misc.git
tree and resend.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH v5] driver: uio: fix possible memory leak in uio_open
  2019-01-31 15:36 ` Greg KH
@ 2019-02-01  1:45   ` liujian (CE)
  0 siblings, 0 replies; 3+ messages in thread
From: liujian (CE) @ 2019-02-01  1:45 UTC (permalink / raw)
  To: Greg KH; +Cc: xiubli, linux-kernel

> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Thursday, January 31, 2019 11:36 PM
> To: liujian (CE) <liujian56@huawei.com>
> Cc: xiubli@redhat.com; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v5] driver: uio: fix possible memory leak in uio_open
> 
> On Wed, Jan 23, 2019 at 06:38:24AM +0800, Liu Jian wrote:
> > 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@huawei.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
> >
> 
> This does not apply to my tree at all :(

I am sorry to have sent so many versions, during which this issue has been resolved by commit 1e09cdd506c8833a9d52cb61009798660cff4051.
So please ignore this patch , and thank you and Xiubo Li in this patch~

> Please rebase it against the char-misc-next branch of my char-misc.git
> tree and resend.
> 
> thanks,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-01  1:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 22:38 [PATCH v5] driver: uio: fix possible memory leak in uio_open Liu Jian
2019-01-31 15:36 ` Greg KH
2019-02-01  1:45   ` liujian (CE)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).