Skip to contentSkip to conversation

Suspicious code in fs/dcache.c:d_delete

DISCUSSION Tero Roponen 1 participant 1 message Feb 24, 2012 VFS

lore
Share & tools
lore
#0 lore raw

While reading the code in fs directory I found some questionable code:

void d_delete(struct dentry * dentry)

{
	...

	inode = dentry->d_inode;
	isdir = S_ISDIR(inode->i_mode);
	if (dentry->d_count == 1) {
		if (inode && !spin_trylock(&inode->i_lock)) {
			spin_unlock(&dentry->d_lock);

	...
}

If inode can become NULL here then dereferencing it without checking in S_ISDIR(inode->i_mode) is wrong. If it cannot be NULL then testing it in 'if (inode && !spin_...)' is not needed.

Signature · 1 line
Tero Roponen