Skip to content

Commit

Permalink
bcache: Fix moving_pred()
Browse files Browse the repository at this point in the history
Avoid a potential null pointer deref (e.g. from check keys for cache misses)

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
  • Loading branch information
Kent Overstreet committed Mar 18, 2014
1 parent da415a0 commit 10d9dcf
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/md/bcache/movinggc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ static bool moving_pred(struct keybuf *buf, struct bkey *k)
moving_gc_keys);
unsigned i;

for (i = 0; i < KEY_PTRS(k); i++) {
struct bucket *g = PTR_BUCKET(c, k, i);

if (GC_MOVE(g))
for (i = 0; i < KEY_PTRS(k); i++)
if (ptr_available(c, k, i) &&
GC_MOVE(PTR_BUCKET(c, k, i)))
return true;
}

return false;
}
Expand Down

0 comments on commit 10d9dcf

Please sign in to comment.