]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
bcache: Fix moving_pred()
authorKent Overstreet <kmo@daterainc.com>
Mon, 17 Feb 2014 23:48:36 +0000 (15:48 -0800)
committerKent Overstreet <kmo@daterainc.com>
Tue, 18 Mar 2014 19:22:34 +0000 (12:22 -0700)
Avoid a potential null pointer deref (e.g. from check keys for cache misses)

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
drivers/md/bcache/movinggc.c

index 8c7205186d081edda0d09030f94753009768e0d0..5e8e58701d37ec45d494a0f7f336316f3428bfc2 100644 (file)
@@ -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;
 }