summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2014-02-18 00:48:36 +0100
committerKent Overstreet <kmo@daterainc.com>2014-03-18 20:22:34 +0100
commit10d9dcf6ee5909e1aabd3685c60fdd1b1306d046 (patch)
tree986a5129e7b107f82e8eacd94ad8f2c6cd78268b /drivers/md
parentbcache: Fix moving_gc deadlocking with a foreground write (diff)
downloadlinux-10d9dcf6ee5909e1aabd3685c60fdd1b1306d046.tar.xz
linux-10d9dcf6ee5909e1aabd3685c60fdd1b1306d046.zip
bcache: Fix moving_pred()
Avoid a potential null pointer deref (e.g. from check keys for cache misses) Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bcache/movinggc.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
index 8c7205186d08..5e8e58701d37 100644
--- a/drivers/md/bcache/movinggc.c
+++ b/drivers/md/bcache/movinggc.c
@@ -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;
}