# \[patch 60/87\] coda: avoid flagging NULL inodes

- From: Andrew Morton \<akpm@linux-foundation.org\>
- Date: 2021-11-09 02:34:42 
- List: linux-mm
- Page: https://ratatoskr.run/linux-mm/2021/11/6512288
- Thread: https://ratatoskr.run/linux-mm/2021/11/6512229/t.md

```text
From: Jan Harkes <jaharkes@cs.cmu.edu>
Subject: coda: avoid flagging NULL inodes

Somehow we hit a negative dentry in coda_rename even after checking with
d_really_is_positive.  Maybe something raced and turned the new_dentry
negative while we were fixing up directory link counts.

Link: https://lkml.kernel.org/r/20210908140308.18491-5-jaharkes@cs.cmu.edu
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
Cc: Alex Shi <redacted>
Cc: Jing Yangyang <redacted>
Cc: Xin Tan <redacted>
Cc: Xiyu Yang <redacted>
Cc: Zeal Robot <redacted>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/coda/coda_linux.h |    3 +++
 1 file changed, 3 insertions(+)

--- a/fs/coda/coda_linux.h~coda-avoid-flagging-null-inodes
+++ a/fs/coda/coda_linux.h
@@ -83,6 +83,9 @@ static __inline__ void coda_flag_inode(s
 {
 	struct coda_inode_info *cii = ITOC(inode);
 
+	if (!inode)
+		return;
+
 	spin_lock(&cii->c_lock);
 	cii->c_flags |= flag;
 	spin_unlock(&cii->c_lock);
_

```
