]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
selinux: Use kmalloc_array() in sidtab_init()
authorMarkus Elfring <elfring@users.sourceforge.net>
Sun, 15 Jan 2017 12:13:19 +0000 (13:13 +0100)
committerPaul Moore <paul@paul-moore.com>
Wed, 29 Mar 2017 15:44:10 +0000 (11:44 -0400)
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/sidtab.c

index 5840a35155fc3d613ec10abceee8420c1b40073f..c9533b21942bbfc6b66c8b2d01bda069ab93693a 100644 (file)
@@ -18,7 +18,7 @@ int sidtab_init(struct sidtab *s)
 {
        int i;
 
-       s->htable = kmalloc(sizeof(*(s->htable)) * SIDTAB_SIZE, GFP_ATOMIC);
+       s->htable = kmalloc_array(SIDTAB_SIZE, sizeof(*s->htable), GFP_ATOMIC);
        if (!s->htable)
                return -ENOMEM;
        for (i = 0; i < SIDTAB_SIZE; i++)