mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
of: do not leak console options
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 <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Rob Herring <[email protected]>
This commit is contained in:
1 parent
8a5776a5f4
commit
db179e0d0d
1 file changed
+6
-2
+6
-2
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user