Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-28 Thread Michael Ellerman
Al Viro writes: > On Mon, Aug 28, 2017 at 02:38:37PM +1000, Paul Mackerras wrote: >> On Sun, Aug 27, 2017 at 10:02:20PM +0100, Al Viro wrote: >> > On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: >> > >> > > It seems to me that it would be better to do

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-28 Thread Michael Ellerman
Al Viro writes: > On Mon, Aug 28, 2017 at 02:38:37PM +1000, Paul Mackerras wrote: >> On Sun, Aug 27, 2017 at 10:02:20PM +0100, Al Viro wrote: >> > On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: >> > >> > > It seems to me that it would be better to do the anon_inode_getfd() >> >

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-28 Thread Paul Mackerras
On Mon, Aug 28, 2017 at 06:28:08AM +0100, Al Viro wrote: > On Mon, Aug 28, 2017 at 02:38:37PM +1000, Paul Mackerras wrote: > > On Sun, Aug 27, 2017 at 10:02:20PM +0100, Al Viro wrote: > > > On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: > > > > > > > It seems to me that it would

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-28 Thread Paul Mackerras
On Mon, Aug 28, 2017 at 06:28:08AM +0100, Al Viro wrote: > On Mon, Aug 28, 2017 at 02:38:37PM +1000, Paul Mackerras wrote: > > On Sun, Aug 27, 2017 at 10:02:20PM +0100, Al Viro wrote: > > > On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: > > > > > > > It seems to me that it would

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-27 Thread Al Viro
On Mon, Aug 28, 2017 at 02:38:37PM +1000, Paul Mackerras wrote: > On Sun, Aug 27, 2017 at 10:02:20PM +0100, Al Viro wrote: > > On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: > > > > > It seems to me that it would be better to do the anon_inode_getfd() > > > call before the

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-27 Thread Al Viro
On Mon, Aug 28, 2017 at 02:38:37PM +1000, Paul Mackerras wrote: > On Sun, Aug 27, 2017 at 10:02:20PM +0100, Al Viro wrote: > > On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: > > > > > It seems to me that it would be better to do the anon_inode_getfd() > > > call before the

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-27 Thread Paul Mackerras
On Sun, Aug 27, 2017 at 10:02:20PM +0100, Al Viro wrote: > On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: > > > It seems to me that it would be better to do the anon_inode_getfd() > > call before the kvm_get_kvm() call, and go to the fail label if it > > fails. > > And what

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-27 Thread Paul Mackerras
On Sun, Aug 27, 2017 at 10:02:20PM +0100, Al Viro wrote: > On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: > > > It seems to me that it would be better to do the anon_inode_getfd() > > call before the kvm_get_kvm() call, and go to the fail label if it > > fails. > > And what

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-27 Thread Al Viro
On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: > It seems to me that it would be better to do the anon_inode_getfd() > call before the kvm_get_kvm() call, and go to the fail label if it > fails. And what happens if another thread does close() on the (guessed) fd?

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-27 Thread Al Viro
On Wed, Aug 23, 2017 at 04:06:24PM +1000, Paul Mackerras wrote: > It seems to me that it would be better to do the anon_inode_getfd() > call before the kvm_get_kvm() call, and go to the fail label if it > fails. And what happens if another thread does close() on the (guessed) fd?

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-23 Thread Nixiaoming
>On 23.08.2017 08:06, Paul Mackerras wrote: >> On Wed, Aug 23, 2017 at 01:43:08AM +, Nixiaoming wrote: On 22.08.2017 17:15, David Hildenbrand wrote: > On 22.08.2017 16:28, nixiaoming wrote: >> miss kfree(stt) when anon_inode_getfd return fail so add check >> anon_inode_getfd

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-23 Thread Nixiaoming
>On 23.08.2017 08:06, Paul Mackerras wrote: >> On Wed, Aug 23, 2017 at 01:43:08AM +, Nixiaoming wrote: On 22.08.2017 17:15, David Hildenbrand wrote: > On 22.08.2017 16:28, nixiaoming wrote: >> miss kfree(stt) when anon_inode_getfd return fail so add check >> anon_inode_getfd

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-23 Thread David Hildenbrand
>>> + mutex_unlock(>lock); >>> + kvm_put_kvm(kvm); >>> + goto fail; >>> + } >>> + return ret; > > of simply > > if (!ret) if (ret >= 0) return ret; is of course what I meant :) > return 0; > > mutex_lock(>lock); >

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-23 Thread David Hildenbrand
>>> + mutex_unlock(>lock); >>> + kvm_put_kvm(kvm); >>> + goto fail; >>> + } >>> + return ret; > > of simply > > if (!ret) if (ret >= 0) return ret; is of course what I meant :) > return 0; > > mutex_lock(>lock); >

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-23 Thread David Hildenbrand
On 23.08.2017 08:06, Paul Mackerras wrote: > On Wed, Aug 23, 2017 at 01:43:08AM +, Nixiaoming wrote: >>> On 22.08.2017 17:15, David Hildenbrand wrote: On 22.08.2017 16:28, nixiaoming wrote: > miss kfree(stt) when anon_inode_getfd return fail so add check > anon_inode_getfd return

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-23 Thread David Hildenbrand
On 23.08.2017 08:06, Paul Mackerras wrote: > On Wed, Aug 23, 2017 at 01:43:08AM +, Nixiaoming wrote: >>> On 22.08.2017 17:15, David Hildenbrand wrote: On 22.08.2017 16:28, nixiaoming wrote: > miss kfree(stt) when anon_inode_getfd return fail so add check > anon_inode_getfd return

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-23 Thread Paul Mackerras
On Wed, Aug 23, 2017 at 01:43:08AM +, Nixiaoming wrote: > >On 22.08.2017 17:15, David Hildenbrand wrote: > >> On 22.08.2017 16:28, nixiaoming wrote: > >>> miss kfree(stt) when anon_inode_getfd return fail so add check > >>> anon_inode_getfd return val, and kfree stt > >>> > >>> Signed-off-by:

Re: Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-23 Thread Paul Mackerras
On Wed, Aug 23, 2017 at 01:43:08AM +, Nixiaoming wrote: > >On 22.08.2017 17:15, David Hildenbrand wrote: > >> On 22.08.2017 16:28, nixiaoming wrote: > >>> miss kfree(stt) when anon_inode_getfd return fail so add check > >>> anon_inode_getfd return val, and kfree stt > >>> > >>> Signed-off-by:

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-22 Thread David Hildenbrand
On 22.08.2017 17:15, David Hildenbrand wrote: > On 22.08.2017 16:28, nixiaoming wrote: >> miss kfree(stt) when anon_inode_getfd return fail >> so add check anon_inode_getfd return val, and kfree stt >> >> Signed-off-by: nixiaoming >> --- >> arch/powerpc/kvm/book3s_64_vio.c

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-22 Thread David Hildenbrand
On 22.08.2017 17:15, David Hildenbrand wrote: > On 22.08.2017 16:28, nixiaoming wrote: >> miss kfree(stt) when anon_inode_getfd return fail >> so add check anon_inode_getfd return val, and kfree stt >> >> Signed-off-by: nixiaoming >> --- >> arch/powerpc/kvm/book3s_64_vio.c | 5 - >> 1 file

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-22 Thread David Hildenbrand
On 22.08.2017 16:28, nixiaoming wrote: > miss kfree(stt) when anon_inode_getfd return fail > so add check anon_inode_getfd return val, and kfree stt > > Signed-off-by: nixiaoming > --- > arch/powerpc/kvm/book3s_64_vio.c | 5 - > 1 file changed, 4 insertions(+), 1

Re: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce

2017-08-22 Thread David Hildenbrand
On 22.08.2017 16:28, nixiaoming wrote: > miss kfree(stt) when anon_inode_getfd return fail > so add check anon_inode_getfd return val, and kfree stt > > Signed-off-by: nixiaoming > --- > arch/powerpc/kvm/book3s_64_vio.c | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git