diff options
| -rw-r--r-- | security/smack/smack_lsm.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 93dc876734a4..2717cdd7872c 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
| @@ -53,6 +53,7 @@ | |||
| 53 | #define SMK_SENDING 2 | 53 | #define SMK_SENDING 2 |
| 54 | 54 | ||
| 55 | LIST_HEAD(smk_ipv6_port_list); | 55 | LIST_HEAD(smk_ipv6_port_list); |
| 56 | static struct kmem_cache *smack_inode_cache; | ||
| 56 | 57 | ||
| 57 | #ifdef CONFIG_SECURITY_SMACK_BRINGUP | 58 | #ifdef CONFIG_SECURITY_SMACK_BRINGUP |
| 58 | static void smk_bu_mode(int mode, char *s) | 59 | static void smk_bu_mode(int mode, char *s) |
| @@ -240,7 +241,7 @@ struct inode_smack *new_inode_smack(struct smack_known *skp) | |||
| 240 | { | 241 | { |
| 241 | struct inode_smack *isp; | 242 | struct inode_smack *isp; |
| 242 | 243 | ||
| 243 | isp = kzalloc(sizeof(struct inode_smack), GFP_NOFS); | 244 | isp = kmem_cache_zalloc(smack_inode_cache, GFP_NOFS); |
| 244 | if (isp == NULL) | 245 | if (isp == NULL) |
| 245 | return NULL; | 246 | return NULL; |
| 246 | 247 | ||
| @@ -767,7 +768,7 @@ static int smack_inode_alloc_security(struct inode *inode) | |||
| 767 | */ | 768 | */ |
| 768 | static void smack_inode_free_security(struct inode *inode) | 769 | static void smack_inode_free_security(struct inode *inode) |
| 769 | { | 770 | { |
| 770 | kfree(inode->i_security); | 771 | kmem_cache_free(smack_inode_cache, inode->i_security); |
| 771 | inode->i_security = NULL; | 772 | inode->i_security = NULL; |
| 772 | } | 773 | } |
| 773 | 774 | ||
| @@ -4265,10 +4266,16 @@ static __init int smack_init(void) | |||
| 4265 | if (!security_module_enable(&smack_ops)) | 4266 | if (!security_module_enable(&smack_ops)) |
| 4266 | return 0; | 4267 | return 0; |
| 4267 | 4268 | ||
| 4269 | smack_inode_cache = KMEM_CACHE(inode_smack, 0); | ||
| 4270 | if (!smack_inode_cache) | ||
| 4271 | return -ENOMEM; | ||
| 4272 | |||
| 4268 | tsp = new_task_smack(&smack_known_floor, &smack_known_floor, | 4273 | tsp = new_task_smack(&smack_known_floor, &smack_known_floor, |
| 4269 | GFP_KERNEL); | 4274 | GFP_KERNEL); |
| 4270 | if (tsp == NULL) | 4275 | if (tsp == NULL) { |
| 4276 | kmem_cache_destroy(smack_inode_cache); | ||
| 4271 | return -ENOMEM; | 4277 | return -ENOMEM; |
| 4278 | } | ||
| 4272 | 4279 | ||
| 4273 | printk(KERN_INFO "Smack: Initializing.\n"); | 4280 | printk(KERN_INFO "Smack: Initializing.\n"); |
| 4274 | 4281 | ||
