Commit 10d9dcf6ee5909e1aabd3685c60fdd1b1306d046
1 parent
da415a096f
Exists in
master
and in
13 other branches
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>
Showing 1 changed file with 3 additions and 5 deletions Side-by-side Diff
drivers/md/bcache/movinggc.c
... | ... | @@ -24,12 +24,10 @@ |
24 | 24 | moving_gc_keys); |
25 | 25 | unsigned i; |
26 | 26 | |
27 | - for (i = 0; i < KEY_PTRS(k); i++) { | |
28 | - struct bucket *g = PTR_BUCKET(c, k, i); | |
29 | - | |
30 | - if (GC_MOVE(g)) | |
27 | + for (i = 0; i < KEY_PTRS(k); i++) | |
28 | + if (ptr_available(c, k, i) && | |
29 | + GC_MOVE(PTR_BUCKET(c, k, i))) | |
31 | 30 | return true; |
32 | - } | |
33 | 31 | |
34 | 32 | return false; |
35 | 33 | } |