Minor improvement of 'smack_sb_kern_mount'
authorJosé Bollo <jose.bollo@open.eurogiciel.org>
Wed, 8 Jan 2014 14:53:05 +0000 (15:53 +0100)
committerCasey Schaufler <casey@schaufler-ca.com>
Fri, 11 Apr 2014 21:33:59 +0000 (14:33 -0700)
Fix a possible memory access fault when transmute is true and isp is NULL.

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

index d814e35987be93b9a643b630f681decd25d0af33..efa42991235e97d4a0f4a9761890b2cbe5b44664 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;