author: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> 2023-06-01 14:42:44 +0800
committer: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2023-07-19 16:36:53 +0200
commit: fd768cc263f3983e7abb40530b3026ada9a37250
parent: d363ac7bd4bb57c3eab458f4c22c0839e1830b34
Commit Summary:
Diffstat:
1 file changed, 9 insertions, 6 deletions
diff --git a/security/integrity/iint.c b/security/integrity/iint.c
index c73858e8c6d5..a462df827de2 100644
--- a/security/integrity/iint.c
+++ b/security/integrity/iint.c
@@ -43,12 +43,10 @@ static struct integrity_iint_cache *__integrity_iint_find(struct inode *inode)
else if (inode > iint->inode)
n = n->rb_right;
else
- break;
+ return iint;
}
- if (!n)
- return NULL;
- return iint;
+ return NULL;
}
/*
@@ -113,10 +111,15 @@ struct integrity_iint_cache *integrity_inode_get(struct inode *inode)
parent = *p;
test_iint = rb_entry(parent, struct integrity_iint_cache,
rb_node);
- if (inode < test_iint->inode)
+ if (inode < test_iint->inode) {
p = &(*p)->rb_left;
- else
+ } else if (inode > test_iint->inode) {
p = &(*p)->rb_right;
+ } else {
+ write_unlock(&integrity_iint_lock);
+ kmem_cache_free(iint_cache, iint);
+ return test_iint;
+ }
}
iint->inode = inode;