Thread (20 messages) read the whole thread 20 messages, 3 authors, 2024-09-02

Re: [PATCH v9 4/5] KVM: arm64: Register ptdump with debugfs on guest creation

From: Sebastian Ene <hidden>
Date: 2024-09-02 13:45:59
Also in: kvmarm, lkml

On Mon, Sep 02, 2024 at 12:13:12PM +0100, Vincent Donnefort wrote:
[...]
quoted
quoted
quoted
+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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help