public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: kvm@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Alex Williamson <alex.williamson@redhat.com>,
	Eric Auger <eric.auger@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] vfio/platform: Use common error handling code in vfio_set_trigger()
Date: Mon, 15 Jan 2024 18:16:01 +0100	[thread overview]
Message-ID: <f1977c1c-1c55-4194-9f72-f77120b2e4e5@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 15 Jan 2024 18:08:29 +0100

Add a jump target so that a bit of exception handling can be better reused
in an if branch of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/vfio/platform/vfio_platform_irq.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c
index 61a1bfb68ac7..8604ce4f3fee 100644
--- a/drivers/vfio/platform/vfio_platform_irq.c
+++ b/drivers/vfio/platform/vfio_platform_irq.c
@@ -193,8 +193,8 @@ static int vfio_set_trigger(struct vfio_platform_device *vdev, int index,

 	trigger = eventfd_ctx_fdget(fd);
 	if (IS_ERR(trigger)) {
-		kfree(irq->name);
-		return PTR_ERR(trigger);
+		ret = PTR_ERR(trigger);
+		goto free_name;
 	}

 	irq->trigger = trigger;
@@ -202,9 +202,10 @@ static int vfio_set_trigger(struct vfio_platform_device *vdev, int index,
 	irq_set_status_flags(irq->hwirq, IRQ_NOAUTOEN);
 	ret = request_irq(irq->hwirq, handler, 0, irq->name, irq);
 	if (ret) {
-		kfree(irq->name);
 		eventfd_ctx_put(trigger);
 		irq->trigger = NULL;
+free_name:
+		kfree(irq->name);
 		return ret;
 	}

--
2.43.0


             reply	other threads:[~2024-01-15 17:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15 17:16 Markus Elfring [this message]
2024-01-15 20:37 ` [PATCH] vfio/platform: Use common error handling code in vfio_set_trigger() Alex Williamson
2024-01-16 11:32   ` Markus Elfring
2024-01-16 18:33     ` Alex Williamson

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=f1977c1c-1c55-4194-9f72-f77120b2e4e5@web.de \
    --to=markus.elfring@web.de \
    --cc=alex.williamson@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox