diff options
author | Kent Overstreet <kmo@daterainc.com> | 2014-02-17 18:48:36 -0500 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-03-18 15:22:34 -0400 |
commit | 10d9dcf6ee5909e1aabd3685c60fdd1b1306d046 (patch) | |
tree | 986a5129e7b107f82e8eacd94ad8f2c6cd78268b | |
parent | da415a096fc06e49d1a15f7a06bcfe6ad44c5d38 (diff) |
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>
-rw-r--r-- | drivers/md/bcache/movinggc.c | 8 |
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) | |||
24 | moving_gc_keys); | 24 | moving_gc_keys); |
25 | unsigned i; | 25 | unsigned i; |
26 | 26 | ||
27 | for (i = 0; i < KEY_PTRS(k); i++) { | 27 | for (i = 0; i < KEY_PTRS(k); i++) |
28 | struct bucket *g = PTR_BUCKET(c, k, i); | 28 | if (ptr_available(c, k, i) && |
29 | 29 | GC_MOVE(PTR_BUCKET(c, k, i))) | |
30 | if (GC_MOVE(g)) | ||
31 | return true; | 30 | return true; |
32 | } | ||
33 | 31 | ||
34 | return false; | 32 | return false; |
35 | } | 33 | } |