From: Sergey Senozhatsky <sergey.senozhatsky.work@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: Tue, 26 Sep 2017 15:25:10 +0900 [thread overview]
Message-ID: <20170926062510.4948-1-sergey.senozhatsky@gmail.com> (raw)
Do not strdup() console options. It seems that the only reason for
it to be strdup()-ed was a compilation warning: printk, UART and
console drivers, for some reason, expect char pointer instead of
const char pointer. So we can just pass `of_stdout_options', but
need to cast it to char pointer. A better fix would be to change
printk, console drivers and UART to accept const char `options';
but that will take time - there are lots of drivers to update.
The patch also fixes a possible memory leak: add_preferred_console()
can fail, but we don't kfree() options.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
drivers/of/base.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 260d33c0f26c..63897531cd75 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1781,8 +1781,12 @@ bool of_console_check(struct device_node *dn, char *name, int index)
{
if (!dn || dn != of_stdout || console_set_on_cmdline)
return false;
- return !add_preferred_console(name, index,
- kstrdup(of_stdout_options, GFP_KERNEL));
+
+ /*
+ * XXX: cast `options' to char pointer to suppress complication
+ * warnings: printk, UART and console drivers expect char pointer.
+ */
+ return !add_preferred_console(name, index, (char *)of_stdout_options);
}
EXPORT_SYMBOL_GPL(of_console_check);
--
2.14.1
next reply other threads:[~2017-09-26 6:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-26 6:25 Sergey Senozhatsky [this message]
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
-- strict thread matches above, loose matches on Subject: below --
2017-08-25 17:36 Sergey Senozhatsky
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
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=20170926062510.4948-1-sergey.senozhatsky@gmail.com \
--to=sergey.senozhatsky.work@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 \
--cc=sergey.senozhatsky@gmail.com \
/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®