[PATCH] fs: dlm: keep room for the final NUL in comm_addr_list_show()

Pengpeng Hou <[email protected]> Wed, 25 Mar 2026 10:26:43 +0800
Newsgroups dev.linux.lists.gfs2,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
comm_addr_list_show() subtracts the formatted address length from the
remaining configfs buffer allowance before appending the string with
strcat(). When the remaining allowance reaches exactly 0, strcat() still
writes the terminating NUL one byte past the 4096-byte configfs buffer.

Only append the next address string when there is still positive space
left after subtracting its visible length, so the trailing NUL stays
inside the output buffer.

Fixes: 55b3286d3dfd ("dlm: show addresses in configfs")
Signed-off-by: Pengpeng Hou <[email protected]>
---
 fs/dlm/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 53cd33293042..94e4e8d3de3d 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -752,7 +752,7 @@ static ssize_t comm_addr_list_show(struct config_item *item, char *buf)
 			break;
 		}
 		allowance -= s;
-		if (allowance >= 0)
+		if (allowance > 0)
 			strcat(buf, buf0);
 		else {
 			allowance += s;
-- 
2.50.1 (Apple Git-155)