Minor improvement of 'smack_sb_kern_mount' 63/23263/1
authorJosé Bollo <jose.bollo@open.eurogiciel.org>
Wed, 8 Jan 2014 14:53:05 +0000 (15:53 +0100)
committerRafal Krypa <r.krypa@samsung.com>
Fri, 20 Jun 2014 15:17:46 +0000 (17:17 +0200)
Fix a possible memory access fault when transmute is true and isp is NULL.

Change-Id: Ib922cfec405067ec5592880c4ae447969ba96633
Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
security/smack/smack_lsm.c

index acd857471f957620711e24832043ca06d83fad3b..0589dee54a11a1858ab473617a4540d30665c62f 100644 (file)
@@ -413,9 +413,11 @@ static int smack_sb_kern_mount(struct super_block *sb, int flags, void *data)
         * Initialize the root inode.
         */
        isp = inode->i_security;
-       if (inode->i_security == NULL) {
-               inode->i_security = new_inode_smack(sp->smk_root);
-               isp = inode->i_security;
+       if (isp == NULL) {
+               isp = new_inode_smack(sp->smk_root);
+               if (isp == NULL)
+                       return -ENOMEM;
+               inode->i_security = isp;
        } else
                isp->smk_inode = sp->smk_root;