[PATCH v9 4/5] KVM: arm64: Register ptdump with debugfs on guest creation
Sebastian Ene
sebastianene at google.com
Mon Sep 2 06:45:56 PDT 2024
On Mon, Sep 02, 2024 at 12:13:12PM +0100, Vincent Donnefort wrote:
> [...]
>
> > > > +static int kvm_ptdump_guest_open(struct inode *m, struct file *file)
> > > > +{
> > > > + struct kvm *kvm = m->i_private;
> > > > + struct kvm_ptdump_guest_state *st;
> > > > + int ret;
> > > > +
> > > > + if (!kvm_get_kvm_safe(kvm))
> > > > + return -ENOENT;
> > > > +
> > > > + st = kvm_ptdump_parser_create(kvm);
> > > > + if (IS_ERR(st)) {
> > > > + ret = PTR_ERR(st);
> > > > + goto free_with_kvm_ref;
> > > > + }
> > > > +
> > > > + ret = single_open(file, kvm_ptdump_guest_show, st);
> > > > + if (!ret)
> > > > + return 0;
> > > > +
> > > > + kfree(st);
> > > > +free_with_kvm_ref:
> > >
> > > nit: I believe kfree understands IS_ERR() so you could have a simple "err:"
> > > label covering all the error path.
> >
> > I couldn't find such handling in kfree(). Could you point be to it?
>
> My aplogies, I was confused by the DEFINE_FREE(kfree ...) for __free(). kfree()
> only checks for null ptr.
>
> Although, I wonder if the naming "free_with_kvm_ref" isn't an artifact from
> previous code? Nothing is freeed here. So perhaps err_with_kvm_ref? which could
> be shorten as this is the only label?
>
> [...]
Yes, I guess that works better. Thanks for checking,
Seb
More information about the linux-arm-kernel
mailing list