Skip to contentSkip to conversation

xfs: don't try to get a reference to a NULL oz in xfs_get_cached_zone

PATCH Applied Christoph Hellwig 3 participants 4 messages Sep 14 – Sep 16 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: don't try to get a reference to a NULL oz in xfs_get_cached_zone

oz can be NULL when we resample it after taking i_flags_lock, so account for that.

Fixes 2d829cc76777 ("xfs: fix racy open zone caching")
---
 fs/xfs/xfs_zone_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_zone_alloc.c +1 -1
index bede79859671..8cdd473d8144 100644
@@ -819,7 +819,7 @@ xfs_get_cached_zone(
 		spin_unlock(&ip->i_flags_lock);
 	}
 
-	if (!atomic_inc_not_zero(&oz->oz_ref))
+	if (oz && !atomic_inc_not_zero(&oz->oz_ref))
 		oz = NULL;
 out_unlock:
 	rcu_read_unlock();
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Christoph Hellwig

oz can be NULL when we resample it after taking i_flags_lock, so account for that.

Fixes 2d829cc76777 ("xfs: fix racy open zone caching")
Quoted 21 lines
---
 fs/xfs/xfs_zone_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_zone_alloc.c +1 -1
index bede79859671..8cdd473d8144 100644
@@ -819,7 +819,7 @@ xfs_get_cached_zone(
 		spin_unlock(&ip->i_flags_lock);
 	}
 
-	if (!atomic_inc_not_zero(&oz->oz_ref))
+	if (oz && !atomic_inc_not_zero(&oz->oz_ref))
 		oz = NULL;
 out_unlock:
 	rcu_read_unlock();
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#2 lore raw
In reply to Christoph Hellwig
Quoted 14 lines · Christoph Hellwig

oz can be NULL when we resample it after taking i_flags_lock, so account for that.

Fixes 2d829cc76777 ("xfs: fix racy open zone caching")
---
 fs/xfs/xfs_zone_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_zone_alloc.c +0 -0
index bede79859671..8cdd473d8144 100644

fs/xfs/xfs_zone_alloc.c xfs_get_cached_zone( · line 825

Quoted 8 lines
fs/xfs/xfs_zone_alloc.c +1 -1
@@ -819,7 +819,7 @@ xfs_get_cached_zone(
 		spin_unlock(&ip->i_flags_lock);
 	}
 
-	if (!atomic_inc_not_zero(&oz->oz_ref))
+	if (oz && !atomic_inc_not_zero(&oz->oz_ref))
 		oz = NULL;
 out_unlock:
 	rcu_read_unlock();

Looks good,

maintainer Applied
#3 lore raw
In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

oz can be NULL when we resample it after taking i_flags_lock, so account for that.

Applied to for-next, thanks!

[1/1] xfs: don't try to get a reference to a NULL oz in xfs_get_cached_zone

      commit: 14e379600d3e57ab0872b049c28cfe5ef519d439

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>