[PATCH 19/61] kvm: Prefer IS_ERR_OR_NULL over manual NULL check

Philipp Hahn
2026-03-10T11:55:44Z

Prefer using IS_ERR_OR_NULL() over using IS_ERR() and a manual NULL
check.

Change generated with coccinelle.

To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Philipp Hahn <phahn-oss@avm.de>
---
virt/kvm/eventfd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 0e8b8a2c5b791243e230a91124d32fcc0250a0c6..4099dd11626009a3497ad09994ba6bc1b8211536 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -508,10 +508,10 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args)
if (irqfd->resampler)
irqfd_resampler_shutdown(irqfd);

- if (resamplefd && !IS_ERR(resamplefd))
+ if (!IS_ERR_OR_NULL(resamplefd))
eventfd_ctx_put(resamplefd);

- if (eventfd && !IS_ERR(eventfd))
+ if (!IS_ERR_OR_NULL(eventfd))
eventfd_ctx_put(eventfd);

out:

--
2.43.0