Re: [PATCH] kvm: kvm_main: Remove unnecessary (void*) conversions

From: Sean Christopherson
Date: Fri Dec 16 2022 - 11:57:11 EST


On Tue, Dec 13, 2022, Li kunyu wrote:
> void * pointer assignment does not require a forced replacement.
>
> Signed-off-by: Li kunyu <kunyu@xxxxxxxxxxxx>
> ---
> virt/kvm/kvm_main.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index fab4d3790578..1682b269ad4a 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3861,7 +3861,7 @@ static int create_vcpu_fd(struct kvm_vcpu *vcpu)
> #ifdef __KVM_HAVE_ARCH_VCPU_DEBUGFS
> static int vcpu_get_pid(void *data, u64 *val)
> {
> - struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data;
> + struct kvm_vcpu *vcpu = data;
> *val = pid_nr(rcu_access_pointer(vcpu->pid));

Unrelated to your patch: doesn't this need proper RCU protection? E.g. if
KVM_RUN changes vcpu->pid between the read and dereference in pid_nr(), and puts
the last reference to the old pid.