VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
author: Wen Yang <wenyang@linux.alibaba.com> 2020-02-19 21:44:42 +0800 committer: Richard Weinberger <richard@nod.at> 2020-03-29 23:20:07 +0200 commit: ba758cfce00a5977ccf019926f8379a96f5ac5f6 parent: 7d7c0568285d6f5630fb269766186afe09e58dc7
Commit Summary:
um: Fix len of file in create_pid_file
Diffstat:
1 file changed, 3 insertions, 2 deletions
diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index 44def53a11cd..9e16078a4bf8 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -220,11 +220,12 @@ static void __init create_pid_file(void)
 	char pid[sizeof("nnnnn\0")], *file;
 	int fd, n;
 
-	file = malloc(strlen(uml_dir) + UMID_LEN + sizeof("/pid\0"));
+	n = strlen(uml_dir) + UMID_LEN + sizeof("/pid\0");
+	file = malloc(n);
 	if (!file)
 		return;
 
-	if (umid_file_name("pid", file, sizeof(file)))
+	if (umid_file_name("pid", file, n))
 		goto out;
 
 	fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644);