From: Artem Bityutskiy Date: Thu, 24 Jan 2008 15:56:14 +0000 (+0200) Subject: UBI: handle zero-length case X-Git-Tag: v2.6.25-rc1~296^2~10^2~3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=60c031531a85b3580f66c2530f9b2802adcad4df;p=karo-tx-linux.git UBI: handle zero-length case ubi_eba_atomic_leb_change() has to just map the LEB to a free PEB if data length is zero. Signed-off-by: Artem Bityutskiy --- diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 1f7375e2ffb8..7ce91ca742b1 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -862,6 +862,17 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, if (ubi->ro_mode) return -EROFS; + if (len == 0) { + /* + * Special case when data length is zero. In this case the LEB + * has to be unmapped and mapped somewhere else. + */ + err = ubi_eba_unmap_leb(ubi, vol, lnum); + if (err) + return err; + return ubi_eba_write_leb(ubi, vol, lnum, NULL, 0, 0, dtype); + } + vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); if (!vid_hdr) return -ENOMEM;