From: Kari Argillander <kari.argillander@gmail.com>
To: Dinghao Liu <dinghao.liu@zju.edu.cn>
Cc: kjlu@umn.edu, "David S. Miller" <davem@davemloft.net>,
linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ide: pci: Fix memleak in ide_pci_init_two
Date: Sun, 20 Dec 2020 21:50:33 +0200 [thread overview]
Message-ID: <20201220195033.due2e4ukijaah23a@kari-VirtualBox> (raw)
In-Reply-To: <20201220070541.7515-1-dinghao.liu@zju.edu.cn>
On Sun, Dec 20, 2020 at 03:05:40PM +0800, Dinghao Liu wrote:
> When do_ide_setup_pci_device() fails, host allocated
> by ide_host_alloc() may not have been freed, which
> leads to memleak.
>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> drivers/ide/setup-pci.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
> index fdc8e813170c..c7da5368fcd4 100644
> --- a/drivers/ide/setup-pci.c
> +++ b/drivers/ide/setup-pci.c
> @@ -586,7 +586,7 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
> * do_ide_setup_pci_device() on the first device!
> */
> if (ret < 0)
> - goto out_free_bars;
> + goto out_free_host;
>
> /* fixup IRQ */
> if (ide_pci_is_in_compatibility_mode(pdev[i])) {
> @@ -597,11 +597,11 @@ int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
> }
>
> ret = ide_host_register(host, d, hws);
> - if (ret)
> - ide_host_free(host);
> - else
> + if (!ret)
> goto out;
Maybe
if (ret)
goto out_free_host;
return 0;
would be more clear here. But this is just small nit.
>
> +out_free_host:
> + ide_host_free(host);
> out_free_bars:
> i = n_ports / 2;
> while (i--)
next prev parent reply other threads:[~2020-12-21 6:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-20 7:05 [PATCH] ide: pci: Fix memleak in ide_pci_init_two Dinghao Liu
2020-12-20 19:50 ` Kari Argillander [this message]
2020-12-23 8:59 ` dinghao.liu
-- strict thread matches above, loose matches on Subject: below --
2020-08-26 9:17 Dinghao Liu
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=20201220195033.due2e4ukijaah23a@kari-VirtualBox \
--to=kari.argillander@gmail.com \
--cc=davem@davemloft.net \
--cc=dinghao.liu@zju.edu.cn \
--cc=kjlu@umn.edu \
--cc=linux-ide@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;
as well as URLs for NNTP newsgroup(s).