Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Xiangyi Zeng <xyzeng@stu.xidian.edu.cn>
Cc: "Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Kishon Vijay Abraham I" <kishon@ti.com>,
	hust-os-kernel-patches@googlegroups.com,
	"Dongliang Mu" <dzm91@hust.edu.cn>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI: dwc: keystone: Free IRQ in `ks_pcie_remove` and the error handling section of `ks_pcie_probe`
Date: Tue, 16 May 2023 14:49:36 -0500	[thread overview]
Message-ID: <ZGPeUNqznHKETgqs@bhelgaas> (raw)
In-Reply-To: <20230516051659.22194-1-xyzeng@stu.xidian.edu.cn>

On Tue, May 16, 2023 at 01:16:59PM +0800, Xiangyi Zeng wrote:
> Smatch complains that:
> drivers/pci/controller/dwc/pci-keystone.c:1303 ks_pcie_probe() warn:
> 'irq' from request_irq() not released on lines: 1183,1187,1303.

Make this the entire warning line from smatch with no extra newlines
inserted.

> "ks-pcie-error-irq" was requested in the `ks_pcie_probe` function, but
> was not freed neither in the error handling part of `ks_pcie_probe`
> nor in the `ks_pcie_remove` function.
> 
> Fix this by adding `free_irq` in `ks_pcie_remove` and in a new error
> handling label `err_alloc` after `err_link` in `ks_pcie_probe`. In
> `ks_pcie_probe`, if `phy` or `link` memory allocation fails, we will
> fall to `err_alloc`. If any other error occurs that leads to
> `err_get_sync` or `err_link`, we end up going to `err_alloc`.

I think the backticks (`) are markdown that makes these "code".
Personally I think ks_pcie_probe() is more readable than
`ks_pcie_probe` since most people (I think) read these in plain-ASCII
situations.  And using backticks for labels and local variables seems
like overkill.

> Fixes: 0790eb175ee0 ("PCI: keystone: Cleanup error_irq configuration")
> Signed-off-by: Xiangyi Zeng <xyzeng@stu.xidian.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>

It's best if the Reviewed-by tag is not added until Dongliang sends
email with that tag directly to the mailing list.  Internal reviews
before posting to the mailing list aren't worth much.

> @@ -1309,12 +1316,14 @@ static int __exit ks_pcie_remove(struct platform_device *pdev)
>  	struct device_link **link = ks_pcie->link;
>  	int num_lanes = ks_pcie->num_lanes;
>  	struct device *dev = &pdev->dev;
> +	int irq = platform_get_irq(pdev, 0);

I think it's better to save the irq we looked up in ks_pcie_probe()
and free *that*.  It's probably the same thing you get by calling
platform_get_irq() again, but it seems cleaner to me to save what we
got in ks_pcie_probe().

>  	pm_runtime_put(dev);
>  	pm_runtime_disable(dev);
>  	ks_pcie_disable_phy(ks_pcie);
>  	while (num_lanes--)
>  		device_link_del(link[num_lanes]);
> +	free_irq(irq, ks_pcie);
>  
>  	return 0;
>  }
> -- 
> 2.34.1
> 

  reply	other threads:[~2023-05-16 19:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16  5:16 [PATCH] PCI: dwc: keystone: Free IRQ in `ks_pcie_remove` and the error handling section of `ks_pcie_probe` Xiangyi Zeng
2023-05-16 19:49 ` Bjorn Helgaas [this message]
2023-05-22  6:07   ` 曾祥翼
2023-05-22 16:10     ` Bjorn Helgaas
2023-05-23  8:05 ` Dan Carpenter

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=ZGPeUNqznHKETgqs@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=dzm91@hust.edu.cn \
    --cc=hust-os-kernel-patches@googlegroups.com \
    --cc=kishon@ti.com \
    --cc=kw@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=robh@kernel.org \
    --cc=xyzeng@stu.xidian.edu.cn \
    /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