]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - ipc/sem.c
Merge tag 'media/v5.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[linux.git] / ipc / sem.c
index 80909464acffb7361dc486b511a1810c3e08b982..7da4504bcc7cfd8c57b897e66608fa3890427fc3 100644 (file)
--- 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;
 }
 
@@ -1680,6 +1676,7 @@ static long ksys_semctl(int semid, int semnum, int cmd, unsigned long arg, int v
        case IPC_SET:
                if (copy_semid_from_user(&semid64, p, version))
                        return -EFAULT;
+               /* fall through */
        case IPC_RMID:
                return semctl_down(ns, semid, cmd, &semid64);
        default: