Merge tag 'integrity-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar...
[linux-2.6-microblaze.git] / security / integrity / ima / ima_main.c
index 0226899..3773009 100644 (file)
@@ -544,8 +544,13 @@ static int __ima_inode_hash(struct inode *inode, struct file *file, char *buf,
 
                rc = ima_collect_measurement(&tmp_iint, file, NULL, 0,
                                             ima_hash_algo, NULL);
-               if (rc < 0)
+               if (rc < 0) {
+                       /* ima_hash could be allocated in case of failure. */
+                       if (rc != -ENOMEM)
+                               kfree(tmp_iint.ima_hash);
+
                        return -EOPNOTSUPP;
+               }
 
                iint = &tmp_iint;
                mutex_lock(&iint->mutex);