From: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
To: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
Cc: Sergey Senozhatsky
<sergey.senozhatsky.work-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Steven Rostedt <rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Sergey Senozhatsky
<sergey.senozhatsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH] of: do not leak console options
Date: Fri, 13 Oct 2017 21:48:34 +0200 [thread overview]
Message-ID: <CAMuHMdXL1v20PvP2=jv_YdNgk0afkrgfZf1b21LrTWXGoPDMhg@mail.gmail.com> (raw)
In-Reply-To: <20171003072007.GB9706-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
On Tue, Oct 3, 2017 at 9:20 AM, Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org> wrote:
> On Tue 2017-09-26 15:25:10, Sergey Senozhatsky wrote:
>> 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> Of course, it would be better to change add_preferred_console().
> But it would trigger many other changes. This alternative
> "temporary" change looks safe to me. Feel free to use
Really? Unless I'm missing something (it's been way too many hours after my
morning coffee), add_preferred_console() just calls __add_preferred_console(),
and the latter doesn't touch the passed string. As passing a "char *" to a
function that excepts a "const char *" is fine, you can just add "const" to
both add_preferred_console() and __add_preferred_console(), and be done with
it.
Repeat after me: casts are evil.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-10-13 19:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-26 6:25 [PATCH] of: do not leak console options Sergey Senozhatsky
2017-10-03 7:20 ` Petr Mladek
[not found] ` <20171003072007.GB9706-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2017-10-13 19:48 ` Geert Uytterhoeven [this message]
[not found] ` <CAMuHMdXL1v20PvP2=jv_YdNgk0afkrgfZf1b21LrTWXGoPDMhg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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
[not found] ` <20170825173647.1004-1-sergey.senozhatsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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
[not found] ` <CAL_JsqKRPGFUzLVbyU_=GZzsy87Mc6x43DtmUQ758-nrZZF_jA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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='CAMuHMdXL1v20PvP2=jv_YdNgk0afkrgfZf1b21LrTWXGoPDMhg@mail.gmail.com' \
--to=geert-td1emuhucqxl1znqvxdv9g@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pmladek-IBi9RG/b67k@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org \
--cc=sergey.senozhatsky-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=sergey.senozhatsky.work-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).