From: Frederic Barrat <fbarrat@linux.ibm.com>
To: Greg Kurz <groug@kaod.org>, linuxppc-dev@lists.ozlabs.org
Cc: Christophe Lombard <clombard@linux.vnet.ibm.com>,
Vaibhav Jain <vaibhav@linux.vnet.ibm.com>,
stable@vger.kernel.org,
Frederic Barrat <fbarrat@linux.vnet.ibm.com>,
Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Subject: Re: [PATCH] ocxl: Clarify error path in setup_xsl_irq()
Date: Mon, 10 Dec 2018 18:18:08 +0100 [thread overview]
Message-ID: <a1efab95-6256-1af3-e159-3f1fae59883d@linux.ibm.com> (raw)
In-Reply-To: <154445509294.867383.14905585855902294361.stgit@bahia.lan>
Le 10/12/2018 à 16:18, Greg Kurz a écrit :
> Implementing rollback with goto and labels is a common practice that
> leads to prettier and more maintainable code. FWIW, this design pattern
> is already being used in alloc_link() a few lines below in this file.
>
> Do the same in setup_xsl_irq().
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
This looks good. I don't have a fixed limit when I start using the "goto
undo" pattern, so it's likely inconsistent in other places as well.
Truth is I'm not too fussed either way.
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
> drivers/misc/ocxl/link.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
> index eed92055184d..659977a17405 100644
> --- a/drivers/misc/ocxl/link.c
> +++ b/drivers/misc/ocxl/link.c
> @@ -273,9 +273,9 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
> spa->irq_name = kasprintf(GFP_KERNEL, "ocxl-xsl-%x-%x-%x",
> link->domain, link->bus, link->dev);
> if (!spa->irq_name) {
> - unmap_irq_registers(spa);
> dev_err(&dev->dev, "Can't allocate name for xsl interrupt\n");
> - return -ENOMEM;
> + rc = -ENOMEM;
> + goto err_xsl;
> }
> /*
> * At some point, we'll need to look into allowing a higher
> @@ -283,11 +283,10 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
> */
> spa->virq = irq_create_mapping(NULL, hwirq);
> if (!spa->virq) {
> - kfree(spa->irq_name);
> - unmap_irq_registers(spa);
> dev_err(&dev->dev,
> "irq_create_mapping failed for translation interrupt\n");
> - return -EINVAL;
> + rc = -EINVAL;
> + goto err_name;
> }
>
> dev_dbg(&dev->dev, "hwirq %d mapped to virq %d\n", hwirq, spa->virq);
> @@ -295,15 +294,21 @@ static int setup_xsl_irq(struct pci_dev *dev, struct link *link)
> rc = request_irq(spa->virq, xsl_fault_handler, 0, spa->irq_name,
> link);
> if (rc) {
> - irq_dispose_mapping(spa->virq);
> - kfree(spa->irq_name);
> - unmap_irq_registers(spa);
> dev_err(&dev->dev,
> "request_irq failed for translation interrupt: %d\n",
> rc);
> - return -EINVAL;
> + rc = -EINVAL;
> + goto err_mapping;
> }
> return 0;
> +
> +err_mapping:
> + irq_dispose_mapping(spa->virq);
> +err_name:
> + kfree(spa->irq_name);
> +err_xsl:
> + unmap_irq_registers(spa);
> + return rc;
> }
>
> static void release_xsl_irq(struct link *link)
>
next prev parent reply other threads:[~2018-12-10 17:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-10 15:18 [PATCH] ocxl: Clarify error path in setup_xsl_irq() Greg Kurz
2018-12-10 17:18 ` Frederic Barrat [this message]
2018-12-11 0:19 ` Andrew Donnellan
2018-12-20 14:52 ` Greg Kurz
2018-12-22 9:54 ` Michael Ellerman
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=a1efab95-6256-1af3-e159-3f1fae59883d@linux.ibm.com \
--to=fbarrat@linux.ibm.com \
--cc=andrew.donnellan@au1.ibm.com \
--cc=clombard@linux.vnet.ibm.com \
--cc=fbarrat@linux.vnet.ibm.com \
--cc=groug@kaod.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=stable@vger.kernel.org \
--cc=vaibhav@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).