Terminate the buffer for sysfs_read_attr() users that might not
properly handle the error code.

Signed-off-by: Dan Williams <[email protected]>
---
 util/sysfs.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/util/sysfs.c b/util/sysfs.c
index e067f065a820..0440fd0f49a3 100644
--- a/util/sysfs.c
+++ b/util/sysfs.c
@@ -39,6 +39,7 @@ int __sysfs_read_attr(struct log_ctx *ctx, const char *path, 
char *buf)
        n = read(fd, buf, SYSFS_ATTR_SIZE);
        close(fd);
        if (n < 0 || n >= SYSFS_ATTR_SIZE) {
+               buf[0] = 0;
                log_dbg(ctx, "failed to read %s: %s\n", path, strerror(errno));
                return -errno;
        }

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to