VisionFive2 Linux kernel

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

More than 9999 Commits   33 Branches   57 Tags
author: Gustavo A. R. Silva <gustavo@embeddedor.com> 2019-03-07 16:30:26 -0800 committer: Linus Torvalds <torvalds@linux-foundation.org> 2019-03-07 18:32:02 -0800 commit: 4a2ae92993be24ba727faa733e99d7980d389ec0 parent: 667da6a2688ab061fcd365de677a0ee880fe2bea
Commit Summary:
ipc/sem.c: replace kvmalloc/memset with kvzalloc and use struct_size
Diffstat:
1 file changed, 1 insertion, 5 deletions
diff --git a/ipc/sem.c b/ipc/sem.c
index a188d1b064ea..7da4504bcc7c 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -488,18 +488,14 @@ static inline void sem_rmid(struct ipc_namespace *ns, struct sem_array *s)
 static struct sem_array *sem_alloc(size_t nsems)
 {
 	struct sem_array *sma;
-	size_t size;
 
 	if (nsems > (INT_MAX - sizeof(*sma)) / sizeof(sma->sems[0]))
 		return NULL;
 
-	size = sizeof(*sma) + nsems * sizeof(sma->sems[0]);
-	sma = kvmalloc(size, GFP_KERNEL);
+	sma = kvzalloc(struct_size(sma, sems, nsems), GFP_KERNEL);
 	if (unlikely(!sma))
 		return NULL;
 
-	memset(sma, 0, size);
-
 	return sma;
 }