* [PATCH] nvmet: fix a width vs precision bug in nvmet_subsys_attr_serial_show()
@ 2021-09-09 9:14 Dan Carpenter
2021-09-09 14:07 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-09-09 9:14 UTC (permalink / raw)
To: Christoph Hellwig, Hannes Reinecke
Cc: Sagi Grimberg, Chaitanya Kulkarni, linux-nvme, kernel-janitors
This was intended to limit the number of characters printed from
"subsys->serial" to NVMET_SN_MAX_SIZE. But accidentally the width
specifier was used instead of the precision specifier so it only
affects the alignment and not the number of characters printed.
Fixes: f04064814c2a ("nvmet: fixup buffer overrun in nvmet_subsys_attr_serial()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/nvme/target/configfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index d784f3c200b4..be5d82421e3a 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -1067,7 +1067,7 @@ static ssize_t nvmet_subsys_attr_serial_show(struct config_item *item,
{
struct nvmet_subsys *subsys = to_subsys(item);
- return snprintf(page, PAGE_SIZE, "%*s\n",
+ return snprintf(page, PAGE_SIZE, "%.*s\n",
NVMET_SN_MAX_SIZE, subsys->serial);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmet: fix a width vs precision bug in nvmet_subsys_attr_serial_show()
2021-09-09 9:14 [PATCH] nvmet: fix a width vs precision bug in nvmet_subsys_attr_serial_show() Dan Carpenter
@ 2021-09-09 14:07 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2021-09-09 14:07 UTC (permalink / raw)
To: Dan Carpenter
Cc: Christoph Hellwig, Hannes Reinecke, Sagi Grimberg,
Chaitanya Kulkarni, linux-nvme, kernel-janitors
Thanks,
applied to nvme-5.15.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-09 14:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-09 9:14 [PATCH] nvmet: fix a width vs precision bug in nvmet_subsys_attr_serial_show() Dan Carpenter
2021-09-09 14:07 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).