From: sashiko-bot@kernel.org
To: "Tao Cui" <cui.tao@linux.dev>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v4 3/3] LoongArch: KVM: Reject repeated PCH-PIC CTRL_INIT
Date: Thu, 15 Oct 2026 23:56:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-173496@kernel.org> (raw)
In-Reply-To: <20261015234638.1077815-4-cui.tao@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] kvm: loongarch: missing rollback of s->device.ops on IO bus registration failure
--
commit d13a3fd9c70a7a0b0118a0e9dbae30ac5e61efaa
Author: Tao Cui <cuitao@kylinos.cn>
LoongArch: KVM: Reject repeated PCH-PIC CTRL_INIT
This commit adds a check to prevent repeated PCH-PIC initialization. It
rejects multiple ioctl calls with -EEXIST by verifying if the device
ops are already populated.
> diff --git a/arch/loongarch/kvm/intc/pch_pic.c b/arch/loongarch/kvm/intc/pch_pic.c
> index 51e4a6a39dc06..a4c35ed704be8 100644
> --- a/arch/loongarch/kvm/intc/pch_pic.c
> +++ b/arch/loongarch/kvm/intc/pch_pic.c
> @@ -281,16 +281,21 @@ static int kvm_pch_pic_init(struct kvm_device *dev, u64 addr)
> struct kvm_io_device *device;
> struct loongarch_pch_pic *s = dev->kvm->arch.pch_pic;
>
> - s->pch_pic_base = addr;
> device = &s->device;
> + mutex_lock(&kvm->slots_lock);
> + if (s->device.ops) {
> + ret = -EEXIST;
> + goto out;
> + }
> + s->pch_pic_base = addr;
> /* init device by pch pic writing and reading ops */
> kvm_iodevice_init(device, &kvm_pch_pic_ops);
> - mutex_lock(&kvm->slots_lock);
> /* register pch pic device */
> ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, addr, PCH_PIC_SIZE, device);
> +out:
> mutex_unlock(&kvm->slots_lock);
>
> - return (ret < 0) ? -EFAULT : 0;
> + return ret;
[Severity: Low]
Does this error path leave the device partially initialized if
kvm_io_bus_register_dev() fails?
If kvm_io_bus_register_dev() returns an error (e.g. -ENOMEM), ret is set
to the error code, but s->device.ops has already been populated by
kvm_iodevice_init() earlier in kvm_pch_pic_init().
Since the function now uses s->device.ops to check for initialization,
would this prevent userspace from retrying the initialization? Subsequent
calls will see s->device.ops populated and return -EEXIST.
> }
>
> /* used by user space to get or set pch pic registers */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015234638.1077815-1-cui.tao@linux.dev?part=3
next prev parent reply other threads:[~2026-10-15 23:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 23:46 [PATCH v4 0/3] LoongArch: KVM: irqchip fixes Tao Cui
2026-10-15 23:46 ` [PATCH v4 1/3] LoongArch: KVM: Clear device pointer in irqchip destroy callbacks Tao Cui
2026-10-16 0:05 ` sashiko-bot
2026-10-16 1:03 ` Bibo Mao
2026-10-15 23:46 ` [PATCH v4 2/3] LoongArch: KVM: Propagate real error code in kvm_pch_pic_create Tao Cui
2026-10-15 23:46 ` [PATCH v4 3/3] LoongArch: KVM: Reject repeated PCH-PIC CTRL_INIT Tao Cui
2026-10-15 23:56 ` sashiko-bot [this message]
2026-10-16 1:03 ` Bibo Mao
2026-10-16 1:31 ` Bibo Mao
2026-10-16 8:01 ` Tao Cui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-173496@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cui.tao@linux.dev \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.