From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Rob Herring <robh+dt@kernel.org>
Cc: Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: [PATCH] of: do not leak console options
Date: Sat, 26 Aug 2017 02:36:47 +0900 [thread overview]
Message-ID: <20170825173647.1004-1-sergey.senozhatsky@gmail.com> (raw)
If add_preferred_console() returns error then we must free a
copy of `of_stdout_options' that we create right before the
console registration.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/of/base.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 260d33c0f26c..9fcf7011d206 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1779,10 +1779,17 @@ EXPORT_SYMBOL_GPL(of_alias_get_highest_id);
*/
bool of_console_check(struct device_node *dn, char *name, int index)
{
+ bool ret;
+ char *options;
+
if (!dn || dn != of_stdout || console_set_on_cmdline)
return false;
- return !add_preferred_console(name, index,
- kstrdup(of_stdout_options, GFP_KERNEL));
+
+ options = kstrdup(of_stdout_options, GFP_KERNEL);
+ ret = add_preferred_console(name, index, options);
+ if (ret)
+ kfree(options);
+ return !ret;
}
EXPORT_SYMBOL_GPL(of_console_check);
--
2.14.1
next reply other threads:[~2017-08-25 17:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-25 17:36 Sergey Senozhatsky [this message]
2017-08-25 22:37 ` Rob Herring
2017-08-27 7:19 ` Sergey Senozhatsky
2017-08-27 8:01 ` Sergey Senozhatsky
2017-09-06 12:40 ` Petr Mladek
2017-09-06 13:29 ` Sergey Senozhatsky
2017-09-06 15:27 ` Rob Herring
2017-09-07 9:57 ` Sergey Senozhatsky
2017-09-26 6:31 ` Sergey Senozhatsky
2017-09-26 6:25 Sergey Senozhatsky
2017-10-03 7:20 ` Petr Mladek
2017-10-13 19:48 ` Geert Uytterhoeven
2017-10-13 20:44 ` Rob Herring
2017-10-12 17:24 ` Rob Herring
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=20170825173647.1004-1-sergey.senozhatsky@gmail.com \
--to=sergey.senozhatsky@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=robh+dt@kernel.org \
--cc=rostedt@goodmis.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
all inboxes | Powered by JetHome®