From: John Garry <john.garry@linux.dev>
To: Arnd Bergmann <arnd@kernel.org>, Keith Busch <kbusch@kernel.org>,
Jens Axboe <axboe@kernel.dk>, Christoph Hellwig <hch@lst.de>,
Sagi Grimberg <sagi@grimberg.me>,
Maurizio Lombardi <mlombard@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Hannes Reinecke <hare@kernel.org>,
Nilay Shroff <nilay@linux.ibm.com>,
John Garry <john.g.garry@oracle.com>,
"Martin K. Petersen" <mkp@kernel.org>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nvme: work around -Wformat-security warning
Date: Thu, 17 Sep 2026 09:01:43 +0100 [thread overview]
Message-ID: <e1ae8618-bfe1-481d-993e-7c7b909899af@linux.dev> (raw)
In-Reply-To: <20260916114533.237863-1-arnd@kernel.org>
On 9/16/26 12:44, Arnd Bergmann wrote:
> From: Arnd Bergmann<arnd@arndb.de>
>
> Passing a string variable into dev_set_name() causes a warning
> when building with -Wformat-security enabled:
>
> drivers/nvme/host/core.c: In function 'nvme_cdev_add':
> drivers/nvme/host/core.c:3911:9: error: format not a string literal and no format arguments [-Werror=format-security]
> 3911 | ret = dev_set_name(cdev_device, name);
>
> Remove the temporary strings and let dev_set_name() do the
> same thing internally.
>
Prior to 26acdaa357cd, we had the caller of nvme_cdev_add() also calling
dev_set_name(). Maybe it is better to revert to that (but keep the
functionality to set NVME_NSHEAD_CDEV_LIVE). But then put_device() call
for errors becomes a bit messy.
...
> }
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index 2cff9fcbf740..e0260f4d24fd 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -1013,9 +1013,9 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
> void nvme_get_ns_head(struct nvme_ns_head *head);
> bool nvme_tryget_ns_head(struct nvme_ns_head *head);
> void nvme_put_ns_head(struct nvme_ns_head *head);
> -int nvme_cdev_add(const char *name, struct cdev *cdev,
> - struct device *cdev_device,
> - const struct file_operations *fops, struct module *owner);
> +int nvme_cdev_add(struct cdev *cdev, struct device *cdev_device,
> + const struct file_operations *fops, struct module *owner,
> + int ctrl, int head);
nit: maybe @head arg would be better called "ns", as it is the "ns" index.
> void nvme_cdev_del(struct cdev *cdev, struct device *cdev_device);
> int nvme_ioctl(struct block_device *bdev, blk_mode_t mode,
> unsigned int cmd, unsigned long arg);
> -- 2.53.0
Regardless of comments:
Reviewed-by: John Garry <john.garry@linux.dev>
next prev parent reply other threads:[~2026-09-17 8:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 11:44 [PATCH] nvme: work around -Wformat-security warning Arnd Bergmann
2026-09-17 3:40 ` Damien Le Moal
2026-09-17 4:14 ` Nilay Shroff
2026-09-17 5:59 ` Arnd Bergmann
2026-09-17 8:01 ` John Garry [this message]
2026-09-17 8:18 ` Nilay Shroff
2026-09-17 19:51 ` Keith Busch
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=e1ae8618-bfe1-481d-993e-7c7b909899af@linux.dev \
--to=john.garry@linux.dev \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=axboe@kernel.dk \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=john.g.garry@oracle.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=mkp@kernel.org \
--cc=mlombard@redhat.com \
--cc=nilay@linux.ibm.com \
--cc=sagi@grimberg.me \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.