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 <bjorn.andersson@linaro.org>
This commit is contained in:
Bjorn Andersson
2020-12-07 08:17:04 -08:00
parent 8a1d24a704
commit 30f5dfb890

View File

@@ -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;