Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'upstream-4.4-rc7' of git://git.infradead.org/linux-ubifs

Pull UBI bug fixes from Richard Weinberger:
"This contains four bug fixes for UBI"

* tag 'upstream-4.4-rc7' of git://git.infradead.org/linux-ubifs:
mtd: ubi: don't leak e if schedule_erase() fails
mtd: ubi: fixup error correction in do_sync_erase()
UBI: fix use of "VID" vs. "EC" in header self-check
UBI: fix return error code

+31 -26
+1 -1
drivers/mtd/ubi/debug.c
··· 236 236 237 237 dfs_rootdir = debugfs_create_dir("ubi", NULL); 238 238 if (IS_ERR_OR_NULL(dfs_rootdir)) { 239 - int err = dfs_rootdir ? -ENODEV : PTR_ERR(dfs_rootdir); 239 + int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV; 240 240 241 241 pr_err("UBI error: cannot create \"ubi\" debugfs directory, error %d\n", 242 242 err);
+1 -1
drivers/mtd/ubi/io.c
··· 1299 1299 if (err && err != UBI_IO_BITFLIPS && !mtd_is_eccerr(err)) 1300 1300 goto exit; 1301 1301 1302 - crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC); 1302 + crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_VID_HDR_SIZE_CRC); 1303 1303 hdr_crc = be32_to_cpu(vid_hdr->hdr_crc); 1304 1304 if (hdr_crc != crc) { 1305 1305 ubi_err(ubi, "bad VID header CRC at PEB %d, calculated %#08x, read %#08x",
+29 -24
drivers/mtd/ubi/wl.c
··· 603 603 return 0; 604 604 } 605 605 606 + static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk); 606 607 /** 607 608 * do_sync_erase - run the erase worker synchronously. 608 609 * @ubi: UBI device description object ··· 616 615 static int do_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, 617 616 int vol_id, int lnum, int torture) 618 617 { 619 - struct ubi_work *wl_wrk; 618 + struct ubi_work wl_wrk; 620 619 621 620 dbg_wl("sync erase of PEB %i", e->pnum); 622 621 623 - wl_wrk = kmalloc(sizeof(struct ubi_work), GFP_NOFS); 624 - if (!wl_wrk) 625 - return -ENOMEM; 622 + wl_wrk.e = e; 623 + wl_wrk.vol_id = vol_id; 624 + wl_wrk.lnum = lnum; 625 + wl_wrk.torture = torture; 626 626 627 - wl_wrk->e = e; 628 - wl_wrk->vol_id = vol_id; 629 - wl_wrk->lnum = lnum; 630 - wl_wrk->torture = torture; 631 - 632 - return erase_worker(ubi, wl_wrk, 0); 627 + return __erase_worker(ubi, &wl_wrk); 633 628 } 634 629 635 630 /** ··· 1011 1014 } 1012 1015 1013 1016 /** 1014 - * erase_worker - physical eraseblock erase worker function. 1017 + * __erase_worker - physical eraseblock erase worker function. 1015 1018 * @ubi: UBI device description object 1016 1019 * @wl_wrk: the work object 1017 1020 * @shutdown: non-zero if the worker has to free memory and exit ··· 1022 1025 * needed. Returns zero in case of success and a negative error code in case of 1023 1026 * failure. 1024 1027 */ 1025 - static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, 1026 - int shutdown) 1028 + static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk) 1027 1029 { 1028 1030 struct ubi_wl_entry *e = wl_wrk->e; 1029 1031 int pnum = e->pnum; ··· 1030 1034 int lnum = wl_wrk->lnum; 1031 1035 int err, available_consumed = 0; 1032 1036 1033 - if (shutdown) { 1034 - dbg_wl("cancel erasure of PEB %d EC %d", pnum, e->ec); 1035 - kfree(wl_wrk); 1036 - wl_entry_destroy(ubi, e); 1037 - return 0; 1038 - } 1039 - 1040 1037 dbg_wl("erase PEB %d EC %d LEB %d:%d", 1041 1038 pnum, e->ec, wl_wrk->vol_id, wl_wrk->lnum); 1042 1039 1043 1040 err = sync_erase(ubi, e, wl_wrk->torture); 1044 1041 if (!err) { 1045 - /* Fine, we've erased it successfully */ 1046 - kfree(wl_wrk); 1047 - 1048 1042 spin_lock(&ubi->wl_lock); 1049 1043 wl_tree_add(e, &ubi->free); 1050 1044 ubi->free_count++; ··· 1052 1066 } 1053 1067 1054 1068 ubi_err(ubi, "failed to erase PEB %d, error %d", pnum, err); 1055 - kfree(wl_wrk); 1056 1069 1057 1070 if (err == -EINTR || err == -ENOMEM || err == -EAGAIN || 1058 1071 err == -EBUSY) { ··· 1060 1075 /* Re-schedule the LEB for erasure */ 1061 1076 err1 = schedule_erase(ubi, e, vol_id, lnum, 0); 1062 1077 if (err1) { 1078 + wl_entry_destroy(ubi, e); 1063 1079 err = err1; 1064 1080 goto out_ro; 1065 1081 } ··· 1134 1148 } 1135 1149 ubi_ro_mode(ubi); 1136 1150 return err; 1151 + } 1152 + 1153 + static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, 1154 + int shutdown) 1155 + { 1156 + int ret; 1157 + 1158 + if (shutdown) { 1159 + struct ubi_wl_entry *e = wl_wrk->e; 1160 + 1161 + dbg_wl("cancel erasure of PEB %d EC %d", e->pnum, e->ec); 1162 + kfree(wl_wrk); 1163 + wl_entry_destroy(ubi, e); 1164 + return 0; 1165 + } 1166 + 1167 + ret = __erase_worker(ubi, wl_wrk); 1168 + kfree(wl_wrk); 1169 + return ret; 1137 1170 } 1138 1171 1139 1172 /**