smack: do not dereference NULL ipc object
[deliverable/linux.git] / security / smack / smack_lsm.c
index 770eb067e165f493b1e153cac3cfcec6d66953f7..38d707593b31851d4b5f0ff78f8072bafc616e7e 100644 (file)
@@ -189,17 +189,10 @@ static void smack_sb_free_security(struct super_block *sb)
  * Copy the Smack specific mount options out of the mount
  * options list.
  */
-static int smack_sb_copy_data(struct file_system_type *type, void *orig,
-                             void *smackopts)
+static int smack_sb_copy_data(char *orig, char *smackopts)
 {
        char *cp, *commap, *otheropts, *dp;
 
-       /* Binary mount data: just copy */
-       if (type->fs_flags & FS_BINARY_MOUNTDATA) {
-               copy_page(smackopts, orig);
-               return 0;
-       }
-
        otheropts = (char *)get_zeroed_page(GFP_KERNEL);
        if (otheropts == NULL)
                return -ENOMEM;
@@ -1515,7 +1508,7 @@ static int smack_shm_associate(struct shmid_kernel *shp, int shmflg)
  */
 static int smack_shm_shmctl(struct shmid_kernel *shp, int cmd)
 {
-       char *ssp = smack_of_shm(shp);
+       char *ssp;
        int may;
 
        switch (cmd) {
@@ -1539,6 +1532,7 @@ static int smack_shm_shmctl(struct shmid_kernel *shp, int cmd)
                return -EINVAL;
        }
 
+       ssp = smack_of_shm(shp);
        return smk_curacc(ssp, may);
 }
 
@@ -1623,7 +1617,7 @@ static int smack_sem_associate(struct sem_array *sma, int semflg)
  */
 static int smack_sem_semctl(struct sem_array *sma, int cmd)
 {
-       char *ssp = smack_of_sem(sma);
+       char *ssp;
        int may;
 
        switch (cmd) {
@@ -1652,6 +1646,7 @@ static int smack_sem_semctl(struct sem_array *sma, int cmd)
                return -EINVAL;
        }
 
+       ssp = smack_of_sem(sma);
        return smk_curacc(ssp, may);
 }
 
@@ -1737,7 +1732,7 @@ static int smack_msg_queue_associate(struct msg_queue *msq, int msqflg)
  */
 static int smack_msg_queue_msgctl(struct msg_queue *msq, int cmd)
 {
-       char *msp = smack_of_msq(msq);
+       char *msp;
        int may;
 
        switch (cmd) {
@@ -1759,6 +1754,7 @@ static int smack_msg_queue_msgctl(struct msg_queue *msq, int cmd)
                return -EINVAL;
        }
 
+       msp = smack_of_msq(msq);
        return smk_curacc(msp, may);
 }
 
This page took 0.030637 seconds and 5 git commands to generate.