BPF List
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: "Enrico Weigelt, metux IT consult" <info@metux.net>
Cc: linux-kernel@vger.kernel.org, pmladek@suse.com,
	rostedt@goodmis.org, sergey.senozhatsky@gmail.com,
	andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk,
	kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
	john.fastabend@gmail.com, kpsingh@kernel.org,
	netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH] lib: vsprintf: check for NULL device_node name in device_node_string()
Date: Thu, 18 Feb 2021 09:47:34 +0900	[thread overview]
Message-ID: <YC25JlDIPl30xPab@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <20210217121543.13010-1-info@metux.net>

On (21/02/17 13:15), Enrico Weigelt, metux IT consult wrote:
> Under rare circumstances it may happen that a device node's name is NULL
> (most likely kernel bug in some other place). 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.
> 
> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
> ---
>  lib/vsprintf.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 3b53c73580c5..050a60b88073 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -2013,6 +2013,10 @@ char *device_node_string(char *buf, char *end, struct device_node *dn,
>  			break;
>  		case 'n':	/* name */
>  			p = fwnode_get_name(of_fwnode_handle(dn));
> +			if (!p) {
> +				pr_warn("device_node without name. Kernel bug ?\n");
> +				p = "<NULL>";
> +			}
>  			precision = str_spec.precision;
>  			str_spec.precision = strchrnul(p, '@') - p;
>  			buf = string(buf, end, p, str_spec);

What about other fwnode_get_name() calls in vsprintf?

	-ss

      parent reply	other threads:[~2021-02-18  0:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17 12:15 [PATCH] lib: vsprintf: check for NULL device_node name in device_node_string() Enrico Weigelt, metux IT consult
2021-02-17 13:50 ` Andy Shevchenko
2021-02-18 12:53   ` Petr Mladek
2021-02-23 19:54     ` Enrico Weigelt, metux IT consult
2021-02-23 19:54   ` Enrico Weigelt, metux IT consult
2021-02-18  0:47 ` Sergey Senozhatsky [this message]

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=YC25JlDIPl30xPab@jagdpanzerIV.localdomain \
    --to=sergey.senozhatsky@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=info@metux.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=netdev@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.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