kvm_pch_pic_create() sets up the default IRQ routing and reports every failure as -ENOMEM, discarding the error code it was given: ret = kvm_setup_default_irq_routing(kvm); if (ret) return -ENOMEM; kvm_setup_default_irq_routing() returns -ENOMEM only when its routing entry array cannot be allocated. Otherwise it forwards the result of kvm_set_irq_routing(), which also fails with -EINVAL when an entry is rejected by setup_routing_entry(). Userspace creating a KVM_DEV_TYPE_LOONGARCH_PCHPIC device can therefore receive -ENOMEM even when IRQ routing setup actually failed with -EINVAL. Return ret so the original error code reaches userspace. This matches kvm_eiointc_create(), which already propagates the error code from the helpers it calls. Only compile-tested. Fixes: 1928254c5ccb ("LoongArch: KVM: Add irqfd support") Signed-off-by: Chaithanya Lagisetty --- arch/loongarch/kvm/intc/pch_pic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c index 2b63b0c2c7ce..7fee60ae01a5 100644 --- a/arch/loongarch/kvm/intc/pch_pic.c +++ b/arch/loongarch/kvm/intc/pch_pic.c @@ -444,7 +444,7 @@ static int kvm_pch_pic_create(struct kvm_device *dev, u32 type) ret = kvm_setup_default_irq_routing(kvm); if (ret) - return -ENOMEM; + return ret; s = kzalloc_obj(struct loongarch_pch_pic); if (!s) -- 2.43.0