linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Nick Desaulniers <nick.desaulniers@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bdi: fix -Wformat-security
Date: Fri, 23 Oct 2020 09:15:03 +0200	[thread overview]
Message-ID: <20201023071503.GA30563@lst.de> (raw)
In-Reply-To: <20201023065754.83084-1-nick.desaulniers@gmail.com>

On Thu, Oct 22, 2020 at 11:57:54PM -0700, Nick Desaulniers wrote:
> mm/backing-dev.c:810:57: warning: format string is not a string literal
> (potentially insecure) [-Wformat-security]
> dev = device_create(bdi_class, NULL, MKDEV(0, 0), bdi, bdi->dev_name);

The callers never pass format strings here.  That being said the fix is
probably ok anyway, modulo the obvious style issue.

> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> index 408d5051d05b..5755578d671d 100644
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -807,7 +807,7 @@ int bdi_register_va(struct backing_dev_info *bdi, const char *fmt, va_list args)
>  		return 0;
>  
>  	vsnprintf(bdi->dev_name, sizeof(bdi->dev_name), fmt, args);
> -	dev = device_create(bdi_class, NULL, MKDEV(0, 0), bdi, bdi->dev_name);
> +	dev = device_create(bdi_class, NULL, MKDEV(0, 0), bdi, "%s", bdi->dev_name);

Please don't introduce any over 80 char lines.


      reply	other threads:[~2020-10-23  7:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23  6:57 Nick Desaulniers
2020-10-23  7:15 ` Christoph Hellwig [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=20201023071503.GA30563@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nick.desaulniers@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