aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <[email protected]>2023-08-11 21:48:14 +0200
committerChristian Brauner <[email protected]>2023-08-15 08:32:45 +0200
commit45e0d4b95b65fedd18aa3e1b6571e16a2e6e0aa9 (patch)
tree2b6aad56f217e7416cc8d37f7545b219340ea055
parent89cbd4c036ba44eadc495820e72c5c36273abb76 (diff)
vfs: fix up the assert in i_readcount_dec
Drops a race where 2 threads could spot a positive value and both proceed to dec to -1, without reporting anything. Signed-off-by: Mateusz Guzik <[email protected]> Message-Id: <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
-rw-r--r--include/linux/fs.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 11055d00fab8..57e2a0a9eea1 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2607,8 +2607,7 @@ static inline bool inode_is_open_for_write(const struct inode *inode)
#if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING)
static inline void i_readcount_dec(struct inode *inode)
{
- BUG_ON(!atomic_read(&inode->i_readcount));
- atomic_dec(&inode->i_readcount);
+ BUG_ON(atomic_dec_return(&inode->i_readcount) < 0);
}
static inline void i_readcount_inc(struct inode *inode)
{