diff options
Diffstat (limited to 'security/selinux/ss/services.c')
-rw-r--r-- | security/selinux/ss/services.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index aecdded55e74..44eb4d74908d 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c | |||
@@ -1531,12 +1531,11 @@ int security_get_user_sids(u32 fromsid, | |||
1531 | } | 1531 | } |
1532 | usercon.user = user->value; | 1532 | usercon.user = user->value; |
1533 | 1533 | ||
1534 | mysids = kmalloc(maxnel*sizeof(*mysids), GFP_ATOMIC); | 1534 | mysids = kcalloc(maxnel, sizeof(*mysids), GFP_ATOMIC); |
1535 | if (!mysids) { | 1535 | if (!mysids) { |
1536 | rc = -ENOMEM; | 1536 | rc = -ENOMEM; |
1537 | goto out_unlock; | 1537 | goto out_unlock; |
1538 | } | 1538 | } |
1539 | memset(mysids, 0, maxnel*sizeof(*mysids)); | ||
1540 | 1539 | ||
1541 | ebitmap_for_each_bit(&user->roles, rnode, i) { | 1540 | ebitmap_for_each_bit(&user->roles, rnode, i) { |
1542 | if (!ebitmap_node_get_bit(rnode, i)) | 1541 | if (!ebitmap_node_get_bit(rnode, i)) |
@@ -1566,13 +1565,12 @@ int security_get_user_sids(u32 fromsid, | |||
1566 | mysids[mynel++] = sid; | 1565 | mysids[mynel++] = sid; |
1567 | } else { | 1566 | } else { |
1568 | maxnel += SIDS_NEL; | 1567 | maxnel += SIDS_NEL; |
1569 | mysids2 = kmalloc(maxnel*sizeof(*mysids2), GFP_ATOMIC); | 1568 | mysids2 = kcalloc(maxnel, sizeof(*mysids2), GFP_ATOMIC); |
1570 | if (!mysids2) { | 1569 | if (!mysids2) { |
1571 | rc = -ENOMEM; | 1570 | rc = -ENOMEM; |
1572 | kfree(mysids); | 1571 | kfree(mysids); |
1573 | goto out_unlock; | 1572 | goto out_unlock; |
1574 | } | 1573 | } |
1575 | memset(mysids2, 0, maxnel*sizeof(*mysids2)); | ||
1576 | memcpy(mysids2, mysids, mynel * sizeof(*mysids2)); | 1574 | memcpy(mysids2, mysids, mynel * sizeof(*mysids2)); |
1577 | kfree(mysids); | 1575 | kfree(mysids); |
1578 | mysids = mysids2; | 1576 | mysids = mysids2; |
@@ -1714,12 +1712,11 @@ int security_get_bools(int *len, char ***names, int **values) | |||
1714 | goto out; | 1712 | goto out; |
1715 | } | 1713 | } |
1716 | 1714 | ||
1717 | *names = (char**)kmalloc(sizeof(char*) * *len, GFP_ATOMIC); | 1715 | *names = (char**)kcalloc(*len, sizeof(char*), GFP_ATOMIC); |
1718 | if (!*names) | 1716 | if (!*names) |
1719 | goto err; | 1717 | goto err; |
1720 | memset(*names, 0, sizeof(char*) * *len); | ||
1721 | 1718 | ||
1722 | *values = (int*)kmalloc(sizeof(int) * *len, GFP_ATOMIC); | 1719 | *values = (int*)kcalloc(*len, sizeof(int), GFP_ATOMIC); |
1723 | if (!*values) | 1720 | if (!*values) |
1724 | goto err; | 1721 | goto err; |
1725 | 1722 | ||