summaryrefslogtreecommitdiff
path: root/drivers/mtd/ubi/wl.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-21 23:03:15 -0300
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-21 23:03:15 -0300
commite899966f626f1f657a4a7bac736c0b9ae5a243ea (patch)
treea4bb8362d871da67b41fee27bb85ad0bc83e0591 /drivers/mtd/ubi/wl.c
parentba0d342ecc21fbbe2f6c178f4479944d1fb34f3b (diff)
parent4b660a7f5c8099d88d1a43d8ae138965112592c7 (diff)
downloadlinux-next-e899966f626f1f657a4a7bac736c0b9ae5a243ea.tar.gz
Merge tag 'v3.15-rc6' into patchwork
Linux 3.15-rc6 * tag 'v3.15-rc6': (1314 commits) Linux 3.15-rc6 Btrfs: send, fix incorrect ref access when using extrefs Btrfs: fix EIO on reading file after ioctl clone works on it scripts/checksyscalls.sh: Make renameat optional asm-generic: Add renameat2 syscall ia64: add renameat2 syscall parisc: add renameat2 syscall m68k: add renameat2 syscall sysfs: make sure read buffer is zeroed ahci: imx: PLL clock needs 100us to settle down PCI: Wrong register used to check pending traffic target: fix memory leak on XCOPY random: fix BUG_ON caused by accounting simplification clk: tegra: Fix wrong value written to PLLE_AUX staging: rtl8723au: Do not reset wdev->iftype in netdev_close() ACPI / video: Revert native brightness quirk for ThinkPad T530 staging: rtl8723au: Use correct pipe type for USB interrupts crush: decode and initialize chooseleaf_vary_r libceph: fix corruption when using page_count 0 page in rbd arm64: fix pud_huge() for 2-level pagetables ...
Diffstat (limited to 'drivers/mtd/ubi/wl.c')
-rw-r--r--drivers/mtd/ubi/wl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 02317c1c0238..0f3425dac910 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -671,6 +671,8 @@ static struct ubi_wl_entry *get_peb_for_wl(struct ubi_device *ubi)
e = find_wl_entry(ubi, &ubi->free, WL_FREE_MAX_DIFF);
self_check_in_wl_tree(ubi, e, &ubi->free);
+ ubi->free_count--;
+ ubi_assert(ubi->free_count >= 0);
rb_erase(&e->u.rb, &ubi->free);
return e;
@@ -684,6 +686,9 @@ int ubi_wl_get_peb(struct ubi_device *ubi)
peb = __wl_get_peb(ubi);
spin_unlock(&ubi->wl_lock);
+ if (peb < 0)
+ return peb;
+
err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset,
ubi->peb_size - ubi->vid_hdr_aloffset);
if (err) {
@@ -1068,6 +1073,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
/* Give the unused PEB back */
wl_tree_add(e2, &ubi->free);
+ ubi->free_count++;
goto out_cancel;
}
self_check_in_wl_tree(ubi, e1, &ubi->used);