mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
nvdimm: ndtest: Return the string length from flags_show()
flags_show() build their output with a seq_buf and return seq_buf_used(), which may include the trailing NUL byte when the seq_buf has overflowed. Use seq_buf_strlen() instead. The flag names are far shorter than the PAGE_SIZE buffer sysfs provides, so this cannot overflow today. Build tested ARCH=x86_64 with GCC 16.2.0, built out of tree with make M=tools/testing/nvdimm: tools/testing/nvdimm/test/ndtest.o Assisted-by: LLM Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Link: https://patch.msgid.link/20261005155708.1471260-11-kees@kernel.org Signed-off-by: Kees Cook <kees@kernel.org>
This commit is contained in:
parent
63ae65caa9
commit
9ac219976e
|
|
@ -693,7 +693,7 @@ static ssize_t flags_show(struct device *dev,
|
|||
if (seq_buf_used(&s))
|
||||
seq_buf_printf(&s, "\n");
|
||||
|
||||
return seq_buf_used(&s);
|
||||
return seq_buf_strlen(&s);
|
||||
}
|
||||
static DEVICE_ATTR_RO(flags);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user