Re: [PATCH v4 1/3] KVM: s390: Add map/unmap ioctl and clean mappings post-guest

Claudio Imbrenda
2026-04-30T15:35:20Z

On Wed, 29 Apr 2026 10:44:51 -0400
Matthew Rosato <mjrosato@linux.ibm.com> wrote:

[...]

>
> > + if (locked)
> > + mmap_read_unlock(mm);
> > + mmput(mm);
> > + }
> > +
> > + return page;
> > +}
> > +
> > +static int kvm_s390_adapter_map(struct kvm *kvm, unsigned int id, __u64 addr)
> > +{
> > + struct s390_io_adapter *adapter = get_io_adapter(kvm, id);
> > + struct s390_map_info *map;
> > + unsigned long flags;
> > + __u64 host_addr;
> > + int ret, idx;
> > +
> > + if (!adapter || !addr)
> > + return -EINVAL;
> > +
> > + map = kzalloc_obj(*map, GFP_KERNEL_ACCOUNT);
> > + if (!map)
> > + return -ENOMEM;
> > +
> > + INIT_LIST_HEAD(&map->list);
> > + idx = srcu_read_lock(&kvm->srcu);
> > + host_addr = gpa_to_hva(kvm, addr);
> > + if (kvm_is_error_hva(host_addr)) {
> > + srcu_read_unlock(&kvm->srcu, idx);
> > + kfree(map);
>
> Drop this kfree(), you already do this when you goto out

have you considered using __free(kvfree) and let the compiler free map
for you automatically? (or it doesn't work here?) …