From: Artem Bityutskiy Date: Mon, 21 May 2007 17:26:05 +0000 (+0300) Subject: UBI: bugfix in ubi_leb_change() X-Git-Tag: v2.6.23-rc1~495^2~16 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a443db48e05a8d2d8db0a17409655c58da65a35e;p=linux-2.6 UBI: bugfix in ubi_leb_change() Do not call 'ubi_wl_put_peb()' if the LEB was unmapped. Reported-by: Gabor Loki Signed-off-by: Artem Bityutskiy --- diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index a1820151e9..0db8dc7af8 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -891,11 +891,13 @@ retry: goto write_error; } - err = ubi_wl_put_peb(ubi, vol->eba_tbl[lnum], 1); - if (err) { - ubi_free_vid_hdr(ubi, vid_hdr); - leb_write_unlock(ubi, vol_id, lnum); - return err; + if (vol->eba_tbl[lnum] >= 0) { + err = ubi_wl_put_peb(ubi, vol->eba_tbl[lnum], 1); + if (err) { + ubi_free_vid_hdr(ubi, vid_hdr); + leb_write_unlock(ubi, vol_id, lnum); + return err; + } } vol->eba_tbl[lnum] = pnum;