Thread (6 messages) 6 messages, 5 authors, 2021-02-23

Re: [PATCH] lib: vsprintf: check for NULL device_node name in device_node_string()

From: Petr Mladek <pmladek@suse.com>
Date: 2021-02-18 15:00:04
Also in: bpf, lkml

On Wed 2021-02-17 15:50:00, Andy Shevchenko wrote:
On Wed, Feb 17, 2021 at 01:15:43PM +0100, Enrico Weigelt, metux IT consult wrote:
quoted
Under rare circumstances it may happen that a device node's name is NULL
(most likely kernel bug in some other place).
What circumstances? How can I reproduce this? More information, please!
quoted
In such situations anything
but helpful, if the debug printout crashes, and nobody knows what actually
happened here.

Therefore protect it by an explicit NULL check and print out an extra
warning.
...
quoted
+				pr_warn("device_node without name. Kernel bug ?\n");
If it's not once, then it's possible to have log spammed with this, right?

...
quoted
+				p = "<NULL>";
We have different standard de facto for NULL pointers to be printed. Actually
if you wish, you may gather them under one definition (maybe somewhere under
printk) and export to everybody to use.
Please, use

	if (check_pointer(&buf, end, p, spec))
		return buf;

It will print "(null)" instead of the name. It should be enough
to inform the user this way. The extra pr_warn() does not help
much to localize the problem anyway. And it is better to avoid
recursion in this path.

Best Regards,
Petr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help