From: Moritz Fischer <mdf@kernel.org>
To: Wen Yang <wen.yang99@zte.com.cn>
Cc: linux-kernel@vger.kernel.org, wang.yi59@zte.com.cn,
Alan Tull <atull@kernel.org>, Moritz Fischer <mdf@kernel.org>,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
linux-fpga@vger.kernel.org
Subject: Re: [PATCH] fpga: stratix10-soc: fix use-after-free on s10_init()
Date: Tue, 23 Apr 2019 17:21:55 -0700 [thread overview]
Message-ID: <20190424002155.GA15154@archbook> (raw)
In-Reply-To: <1556062325-26141-1-git-send-email-wen.yang99@zte.com.cn>
Hi Wen,
On Wed, Apr 24, 2019 at 07:32:05AM +0800, Wen Yang wrote:
> The refcount of fw_np has already been decreased by of_find_matching_node()
> so it shouldn't be used anymore.
> This patch adds an of_node_get() before of_find_matching_node() to avoid
> the use-after-free problem.
>
> Fixes: e7eef1d7633a ("fpga: add intel stratix10 soc fpga manager driver")
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Alan Tull <atull@kernel.org>
> Cc: Moritz Fischer <mdf@kernel.org>
> Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Cc: linux-fpga@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
Reviewed-by: Moritz Fischer <mdf@kernel.org>
> ---
> drivers/fpga/stratix10-soc.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c
> index 13851b3..215d337 100644
> --- a/drivers/fpga/stratix10-soc.c
> +++ b/drivers/fpga/stratix10-soc.c
> @@ -507,12 +507,16 @@ static int __init s10_init(void)
> if (!fw_np)
> return -ENODEV;
>
> + of_node_get(fw_np);
> np = of_find_matching_node(fw_np, s10_of_match);
> - if (!np)
> + if (!np) {
> + of_node_put(fw_np);
> return -ENODEV;
> + }
>
> of_node_put(np);
> ret = of_platform_populate(fw_np, s10_of_match, NULL, NULL);
> + of_node_put(fw_np);
> if (ret)
> return ret;
>
> --
> 2.9.5
>
Thanks,
Moritz
next prev parent reply other threads:[~2019-04-24 0:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-23 23:32 [PATCH] fpga: stratix10-soc: fix use-after-free on s10_init() Wen Yang
2019-04-24 0:21 ` Moritz Fischer [this message]
2019-04-24 11:22 ` Nicolas Saenz Julienne
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=20190424002155.GA15154@archbook \
--to=mdf@kernel.org \
--cc=atull@kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nsaenzjulienne@suse.de \
--cc=wang.yi59@zte.com.cn \
--cc=wen.yang99@zte.com.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.