public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: kvm: remove NULL check before kfree
@ 2022-06-14  8:50 Dongliang Mu
  2022-06-14 12:01 ` Vitaly Kuznetsov
  0 siblings, 1 reply; 3+ messages in thread
From: Dongliang Mu @ 2022-06-14  8:50 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin
  Cc: mudongliang, kvm, linux-kernel

From: mudongliang <mudongliangabcd@gmail.com>

kfree can handle NULL pointer as its argument.
According to coccinelle isnullfree check, remove NULL check
before kfree operation.

Signed-off-by: mudongliang <mudongliangabcd@gmail.com>
---
 arch/x86/kernel/kvm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 1a3658f7e6d9..d4e48b4a438b 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -236,8 +236,7 @@ void kvm_async_pf_task_wake(u32 token)
 	raw_spin_unlock(&b->lock);
 
 	/* A dummy token might be allocated and ultimately not used.  */
-	if (dummy)
-		kfree(dummy);
+	kfree(dummy);
 }
 EXPORT_SYMBOL_GPL(kvm_async_pf_task_wake);
 
-- 
2.35.1


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

* Re: [PATCH] x86: kvm: remove NULL check before kfree
  2022-06-14  8:50 [PATCH] x86: kvm: remove NULL check before kfree Dongliang Mu
@ 2022-06-14 12:01 ` Vitaly Kuznetsov
  2022-06-14 13:36   ` Dongliang Mu
  0 siblings, 1 reply; 3+ messages in thread
From: Vitaly Kuznetsov @ 2022-06-14 12:01 UTC (permalink / raw)
  To: Dongliang Mu
  Cc: Paolo Bonzini, Sean Christopherson, Wanpeng Li, Jim Mattson,
	Joerg Roedel, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, mudongliang, kvm, linux-kernel

Dongliang Mu <dzm91@hust.edu.cn> writes:

> From: mudongliang <mudongliangabcd@gmail.com>
>
> kfree can handle NULL pointer as its argument.
> According to coccinelle isnullfree check, remove NULL check
> before kfree operation.
>
> Signed-off-by: mudongliang <mudongliangabcd@gmail.com>
> ---
>  arch/x86/kernel/kvm.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index 1a3658f7e6d9..d4e48b4a438b 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -236,8 +236,7 @@ void kvm_async_pf_task_wake(u32 token)
>  	raw_spin_unlock(&b->lock);
>  
>  	/* A dummy token might be allocated and ultimately not used.  */
> -	if (dummy)
> -		kfree(dummy);
> +	kfree(dummy);
>  }
>  EXPORT_SYMBOL_GPL(kvm_async_pf_task_wake);

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

-- 
Vitaly


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

* Re: [PATCH] x86: kvm: remove NULL check before kfree
  2022-06-14 12:01 ` Vitaly Kuznetsov
@ 2022-06-14 13:36   ` Dongliang Mu
  0 siblings, 0 replies; 3+ messages in thread
From: Dongliang Mu @ 2022-06-14 13:36 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: Dongliang Mu, Paolo Bonzini, Sean Christopherson, Wanpeng Li,
	Jim Mattson, Joerg Roedel, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, kvm,
	linux-kernel

On Tue, Jun 14, 2022 at 8:01 PM Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>
> Dongliang Mu <dzm91@hust.edu.cn> writes:
>
> > From: mudongliang <mudongliangabcd@gmail.com>
> >
> > kfree can handle NULL pointer as its argument.
> > According to coccinelle isnullfree check, remove NULL check
> > before kfree operation.
> >
> > Signed-off-by: mudongliang <mudongliangabcd@gmail.com>
> > ---
> >  arch/x86/kernel/kvm.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> > index 1a3658f7e6d9..d4e48b4a438b 100644
> > --- a/arch/x86/kernel/kvm.c
> > +++ b/arch/x86/kernel/kvm.c
> > @@ -236,8 +236,7 @@ void kvm_async_pf_task_wake(u32 token)
> >       raw_spin_unlock(&b->lock);
> >
> >       /* A dummy token might be allocated and ultimately not used.  */
> > -     if (dummy)
> > -             kfree(dummy);
> > +     kfree(dummy);
> >  }
> >  EXPORT_SYMBOL_GPL(kvm_async_pf_task_wake);
>
> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

Thanks for your review. My signature seems with an incorrect format,
so I send a v2 patch.


>
> --
> Vitaly
>

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

end of thread, other threads:[~2022-06-14 13:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-14  8:50 [PATCH] x86: kvm: remove NULL check before kfree Dongliang Mu
2022-06-14 12:01 ` Vitaly Kuznetsov
2022-06-14 13:36   ` Dongliang Mu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox