Unverified Commit a49c547e authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!2687 integrity: Fix possible multiple allocation in integrity_inode_get()

parents 118901df 6b517c71
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -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;
}

/*
@@ -121,10 +119,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;