Pārlūkot izejas kodu

UBI: fix kmem_cache_free on error patch

'kmem_cache_free()' oopeses if NULL is passed, and there is
one error-path place where UBI may call it with NULL object.
This problem was pointed to by Adrian Hunter.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Artem Bityutskiy 16 gadi atpakaļ
vecāks
revīzija
21d08bbcb1
1 mainītis faili ar 2 papildinājumiem un 1 dzēšanām
  1. 2 1
      drivers/mtd/ubi/wl.c

+ 2 - 1
drivers/mtd/ubi/wl.c

@@ -826,7 +826,8 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
 	err = schedule_erase(ubi, e1, 0);
 	if (err) {
 		kmem_cache_free(ubi_wl_entry_slab, e1);
-		kmem_cache_free(ubi_wl_entry_slab, e2);
+		if (e2)
+			kmem_cache_free(ubi_wl_entry_slab, e2);
 		goto out_ro;
 	}