Skip to content

Commit 6d48e61

Browse files
author
Kent Overstreet
committed
bcachefs: Add missing guard in bch2_snapshot_has_children()
We additionally need to be going inconsistent if passed an invalid snapshot ID; that patch will need more thorough testing. Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 6ce26ad commit 6d48e61

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

fs/bcachefs/snapshot.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,9 @@ static inline bool bch2_snapshot_is_ancestor(struct bch_fs *c, u32 id, u32 ances
176176

177177
static inline bool bch2_snapshot_has_children(struct bch_fs *c, u32 id)
178178
{
179-
const struct snapshot_t *t;
180-
bool ret;
181-
182179
rcu_read_lock();
183-
t = snapshot_t(c, id);
184-
ret = (t->children[0]|t->children[1]) != 0;
180+
const struct snapshot_t *t = snapshot_t(c, id);
181+
bool ret = t && (t->children[0]|t->children[1]) != 0;
185182
rcu_read_unlock();
186183

187184
return ret;

0 commit comments

Comments
 (0)