Explorar o código

bcache: Fix a null ptr deref in journal replay

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Kent Overstreet %!s(int64=12) %!d(string=hai) anos
pai
achega
65ddf45a31
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      drivers/md/bcache/journal.c

+ 5 - 1
drivers/md/bcache/journal.c

@@ -287,9 +287,13 @@ void bch_journal_mark(struct cache_set *c, struct list_head *list)
 		     k < bset_bkey_last(&i->j);
 		     k = bkey_next(k)) {
 			unsigned j;
+			struct bucket *g;
 
 			for (j = 0; j < KEY_PTRS(k); j++) {
-				struct bucket *g = PTR_BUCKET(c, k, j);
+				if (!ptr_available(c, k, j))
+					continue;
+
+				g = PTR_BUCKET(c, k, j);
 				atomic_inc(&g->pin);
 
 				if (g->prio == BTREE_PRIO &&