From 30f5dfb8903d7e8da1d79cb5106089c09de01ff7 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Mon, 7 Dec 2020 08:17:04 -0800 Subject: [PATCH] rproc: NUL-terminate the modalias According to valgrind the modalias read from the remoteproc device is not NUL-terminated, so do this to avoid reading in the weeds. Signed-off-by: Bjorn Andersson --- rproc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rproc.c b/rproc.c index 3f17a74..50f1668 100644 --- a/rproc.c +++ b/rproc.c @@ -55,9 +55,10 @@ static int rproc_init_by_modalias(void) if (modalias_fd < 0) goto close_rproc_fd; - ret = read(modalias_fd, modalias, sizeof(modalias)); + ret = read(modalias_fd, modalias, sizeof(modalias) - 1); if (ret < 0) goto close_modalias_fd; + modalias[ret] = '\0'; if (!strstr(modalias, "-mpss-pas") && !strstr(modalias, "-mss-pil")) goto close_modalias_fd;