From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
To: Wen Yang <wen.yang99@zte.com.cn>, linux-kernel@vger.kernel.org
Cc: wang.yi59@zte.com.cn, Alan Tull <atull@kernel.org>,
Moritz Fischer <mdf@kernel.org>,
linux-fpga@vger.kernel.org
Subject: Re: [PATCH] fpga: stratix10-soc: fix use-after-free on s10_init()
Date: Wed, 24 Apr 2019 13:22:29 +0200 [thread overview]
Message-ID: <efb56be4292ec510c56393fd3c90d3dc15e6c509.camel@suse.de> (raw)
In-Reply-To: <1556062325-26141-1-git-send-email-wen.yang99@zte.com.cn>
[-- Attachment #1: Type: text/plain, Size: 1421 bytes --]
Hi Thanks,
On Wed, 2019-04-24 at 07:32 +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
> ---
> 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;
>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Regards,
Nicolas
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2019-04-24 11:22 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
2019-04-24 11:22 ` Nicolas Saenz Julienne [this message]
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=efb56be4292ec510c56393fd3c90d3dc15e6c509.camel@suse.de \
--to=nsaenzjulienne@suse.de \
--cc=atull@kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdf@kernel.org \
--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 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).