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,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Tull <atull@kernel.org>,
Richard Gong <richard.gong@intel.com>
Subject: Re: [PATCH 3/3] firmware: stratix10-svc: fix leaked of_node references
Date: Wed, 17 Apr 2019 13:32:35 +0200 [thread overview]
Message-ID: <1eba0edb8cc1b7136aac218cdb6696f92d8dbf20.camel@suse.de> (raw)
In-Reply-To: <1555469093-35179-4-git-send-email-wen.yang99@zte.com.cn>
[-- Attachment #1: Type: text/plain, Size: 2352 bytes --]
On Wed, 2019-04-17 at 10:44 +0800, Wen Yang wrote:
> In stratix10_svc_init function, fw_np is obtained by calling
> of_find_node_by_name(), np is obtained by calling
> of_find_matching_node(), and the reference counts of those
> two device_nodes, fw_np and np, are increased.
> But when the function exits, only of_node_put is called on np,
> and fw_np's reference count is leaked.
>
> Detected by coccinelle with the following warnings:
> ./drivers/firmware/stratix10-svc.c:1020:2-8: ERROR: missing of_node_put;
> acquired a node pointer with refcount incremented on line 1014, but without a
> corresponding object release within this function.
> ./drivers/firmware/stratix10-svc.c:1025:2-8: ERROR: missing of_node_put;
> acquired a node pointer with refcount incremented on line 1014, but without a
> corresponding object release within this function.
> ./drivers/firmware/stratix10-svc.c:1027:1-7: ERROR: missing of_node_put;
> acquired a node pointer with refcount incremented on line 1014, but without a
> corresponding object release within this function.
>
> Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Alan Tull <atull@kernel.org>
> Cc: Richard Gong <richard.gong@intel.com>
> Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Cc: linux-kernel@vger.kernel.org
> ---
> drivers/firmware/stratix10-svc.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-
> svc.c
> index 6e65148..482a6bd 100644
> --- a/drivers/firmware/stratix10-svc.c
> +++ b/drivers/firmware/stratix10-svc.c
> @@ -1016,15 +1016,21 @@ static int __init stratix10_svc_init(void)
> return -ENODEV;
>
> np = of_find_matching_node(fw_np, stratix10_svc_drv_match);
Sorry but this patch isn't right, of_find_matching_node() will free the
reference to fw_np internally.
> - if (!np)
> - return -ENODEV;
> + if (!np) {
> + ret = -ENODEV;
> + goto out_put_fw_np;
> + }
>
> of_node_put(np);
> ret = of_platform_populate(fw_np, stratix10_svc_drv_match, NULL, NULL);
> if (ret)
> - return ret;
> + goto out_put_fw_np;
Consequently and assuming I'm not missing something, I think fw_np shouldn't be
used here as is.
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-17 11:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 2:44 [PATCH 0/3] fix leaked of_node references in drivers/firmware Wen Yang
2019-04-17 2:44 ` [PATCH 1/3] firmware: arm_sdei: fix leaked of_node references Wen Yang
2019-04-17 2:44 ` [PATCH 2/3] firmware: psci: " Wen Yang
2019-04-17 2:44 ` [PATCH 3/3] firmware: stratix10-svc: " Wen Yang
2019-04-17 11:32 ` 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=1eba0edb8cc1b7136aac218cdb6696f92d8dbf20.camel@suse.de \
--to=nsaenzjulienne@suse.de \
--cc=atull@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard.gong@intel.com \
--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
all inboxes | Powered by JetHome®