This pull request contains the following changes for UBI and UBIFS:
UBIFS: - Misc code cleanups such as removal of unnecessary variables UBI: - No longer program unused bit in UBI headers -----BEGIN PGP SIGNATURE----- iQJmBAABCABQFiEEdgfidid8lnn52cLTZvlZhesYu8EFAmkz9QIbFIAAAAAABAAO bWFudTIsMi41KzEuMTEsMiwyFhxyaWNoYXJkQHNpZ21hLXN0YXIuYXQACgkQZvlZ hesYu8HQIQ//YKQkpUYoMFhPARL4TArC5d0TK7MneiEj4DfrW+tELxIMc2Sy3i6L Ltd7np9dWrcPSbsdfw4erFARoYoXQfLql/qhc9UlnlUtPyGhFHu6MgSd4o4XPYeL 4oMS39rzZBJU+Vl6Hp/uo1uv5wjHG4qEHouNaVHbs5aM9+gEOisyVq2MswSm10Ja cjkJN1iwtrGnzxCloD/RbIOFx/Y1BGhzNnJpudu+i7PY2LVoUhCPex9QKRuGOpIY DDt7OwfxFhitGs24y2QzQL9bsCjP/OpvOcv8PAgUaChhkzd7RV7Hh24AjD9xjXH0 h7Yyx1Qs6phVfES7tUHqiFT4YptsipsoNFnoh+kDbkv9MDsGtjJ8Qp1xcgH2AYVD A4MF29oewRc9KcNZ2C8yVSPcnz9c6bf73BnOguFKa8uLZGkRxO1Vds6tbK0pj3ef C+Sj2BV0YtDx7yfUgvcHpOavAkyWV8hgyYblV2wUoLvLDhsq5LuFXAt3xwsG8h4k N15A057aoWyFyRapfpoiGTATcVS4XyYhxc+VueRO35daEuXULpL/BEOZnJixdRz6 ThJhr8auIIlzu31qsp26VkAYKPXK3hwDWW8Z7MZzUVWjVI3tkusYSuNYSYdQ7HtE jP52mfwf2ryxbgHVmNieDmBO6T+HFTQ8dbOV0ZAB/Eu7dtxDT6nnimk= =Y3kr -----END PGP SIGNATURE----- Merge tag 'ubifs-for-linus-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs Pull UBI and UBIFS updates from Richard Weinberger: "UBIFS: - Misc code cleanups such as removal of unnecessary variables UBI: - No longer program unused bit in UBI headers" * tag 'ubifs-for-linus-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/ubifs: ubifs: vmalloc(array_size()) -> vmalloc_array() ubi: fastmap: fix ubi->fm memory leak mtd: ubi: skip programming unused bits in ubi headers ubifs: Remove unnecessary variable assignments ubifs: Simplify the code using ubifs_crc_node ubifs: Remove unnecessary parameters '*c'master
commit
70e3083ec6
|
|
@ -1600,7 +1600,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
|
|||
|
||||
err = ubi_read_volume_table(ubi, ai);
|
||||
if (err)
|
||||
goto out_ai;
|
||||
goto out_fm;
|
||||
|
||||
err = ubi_wl_init(ubi, ai);
|
||||
if (err)
|
||||
|
|
@ -1642,6 +1642,8 @@ out_wl:
|
|||
out_vtbl:
|
||||
ubi_free_all_volumes(ubi);
|
||||
vfree(ubi->vtbl);
|
||||
out_fm:
|
||||
ubi_free_fastmap(ubi);
|
||||
out_ai:
|
||||
destroy_ai(ai);
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -530,8 +530,6 @@ int ubi_is_erase_work(struct ubi_work *wrk)
|
|||
|
||||
static void ubi_fastmap_close(struct ubi_device *ubi)
|
||||
{
|
||||
int i;
|
||||
|
||||
return_unused_pool_pebs(ubi, &ubi->fm_pool);
|
||||
return_unused_pool_pebs(ubi, &ubi->fm_wl_pool);
|
||||
|
||||
|
|
@ -540,11 +538,7 @@ static void ubi_fastmap_close(struct ubi_device *ubi)
|
|||
ubi->fm_anchor = NULL;
|
||||
}
|
||||
|
||||
if (ubi->fm) {
|
||||
for (i = 0; i < ubi->fm->used_blocks; i++)
|
||||
kfree(ubi->fm->e[i]);
|
||||
}
|
||||
kfree(ubi->fm);
|
||||
ubi_free_fastmap(ubi);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -868,6 +868,8 @@ int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum,
|
|||
return -EROFS;
|
||||
}
|
||||
|
||||
memset((char *)ec_hdr + UBI_EC_HDR_SIZE, 0xFF, ubi->ec_hdr_alsize - UBI_EC_HDR_SIZE);
|
||||
|
||||
err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize);
|
||||
return err;
|
||||
}
|
||||
|
|
@ -1150,6 +1152,14 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
|
|||
return -EROFS;
|
||||
}
|
||||
|
||||
if (ubi->vid_hdr_shift) {
|
||||
memset((char *)p, 0xFF, ubi->vid_hdr_shift);
|
||||
memset((char *)p + ubi->vid_hdr_shift + UBI_VID_HDR_SIZE, 0xFF,
|
||||
ubi->vid_hdr_alsize - (ubi->vid_hdr_shift + UBI_VID_HDR_SIZE));
|
||||
} else {
|
||||
memset((char *)p + UBI_VID_HDR_SIZE, 0xFF, ubi->vid_hdr_alsize - UBI_VID_HDR_SIZE);
|
||||
}
|
||||
|
||||
err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset,
|
||||
ubi->vid_hdr_alsize);
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -969,10 +969,22 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
|
|||
struct ubi_attach_info *scan_ai);
|
||||
int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count);
|
||||
void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol);
|
||||
static inline void ubi_free_fastmap(struct ubi_device *ubi)
|
||||
{
|
||||
if (ubi->fm) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ubi->fm->used_blocks; i++)
|
||||
kmem_cache_free(ubi_wl_entry_slab, ubi->fm->e[i]);
|
||||
kfree(ubi->fm);
|
||||
ubi->fm = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static inline int ubi_update_fastmap(struct ubi_device *ubi) { return 0; }
|
||||
static inline int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count) { return 0; }
|
||||
static inline void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol) {}
|
||||
static inline void ubi_free_fastmap(struct ubi_device *ubi) { }
|
||||
#endif
|
||||
|
||||
/* block.c */
|
||||
|
|
|
|||
|
|
@ -327,8 +327,6 @@ out:
|
|||
*/
|
||||
void ubifs_pad(const struct ubifs_info *c, void *buf, int pad)
|
||||
{
|
||||
uint32_t crc;
|
||||
|
||||
ubifs_assert(c, pad >= 0);
|
||||
|
||||
if (pad >= UBIFS_PAD_NODE_SZ) {
|
||||
|
|
@ -343,8 +341,7 @@ void ubifs_pad(const struct ubifs_info *c, void *buf, int pad)
|
|||
ch->len = cpu_to_le32(UBIFS_PAD_NODE_SZ);
|
||||
pad -= UBIFS_PAD_NODE_SZ;
|
||||
pad_node->pad_len = cpu_to_le32(pad);
|
||||
crc = crc32(UBIFS_CRC32_INIT, buf + 8, UBIFS_PAD_NODE_SZ - 8);
|
||||
ch->crc = cpu_to_le32(crc);
|
||||
ubifs_crc_node(buf, UBIFS_PAD_NODE_SZ);
|
||||
memset(buf + UBIFS_PAD_NODE_SZ, 0, pad);
|
||||
} else if (pad > 0)
|
||||
/* Too little space, padding node won't fit */
|
||||
|
|
@ -395,7 +392,7 @@ void ubifs_init_node(struct ubifs_info *c, void *node, int len, int pad)
|
|||
}
|
||||
}
|
||||
|
||||
void ubifs_crc_node(struct ubifs_info *c, void *node, int len)
|
||||
void ubifs_crc_node(void *node, int len)
|
||||
{
|
||||
struct ubifs_ch *ch = node;
|
||||
uint32_t crc;
|
||||
|
|
@ -432,7 +429,7 @@ int ubifs_prepare_node_hmac(struct ubifs_info *c, void *node, int len,
|
|||
return err;
|
||||
}
|
||||
|
||||
ubifs_crc_node(c, node, len);
|
||||
ubifs_crc_node(node, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -469,7 +466,6 @@ void ubifs_prepare_node(struct ubifs_info *c, void *node, int len, int pad)
|
|||
*/
|
||||
void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
|
||||
{
|
||||
uint32_t crc;
|
||||
struct ubifs_ch *ch = node;
|
||||
unsigned long long sqnum = next_sqnum(c);
|
||||
|
||||
|
|
@ -483,8 +479,7 @@ void ubifs_prep_grp_node(struct ubifs_info *c, void *node, int len, int last)
|
|||
ch->group_type = UBIFS_IN_NODE_GROUP;
|
||||
ch->sqnum = cpu_to_le64(sqnum);
|
||||
ch->padding[0] = ch->padding[1] = 0;
|
||||
crc = crc32(UBIFS_CRC32_INIT, node + 8, len - 8);
|
||||
ch->crc = cpu_to_le32(crc);
|
||||
ubifs_crc_node(node, len);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -628,8 +628,8 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
|
|||
pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL);
|
||||
nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL);
|
||||
buf = vmalloc(c->leb_size);
|
||||
ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
|
||||
c->lpt_lebs));
|
||||
ltab = vmalloc_array(c->lpt_lebs,
|
||||
sizeof(struct ubifs_lpt_lprops));
|
||||
if (!pnode || !nnode || !buf || !ltab || !lsave) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
|
|
@ -1777,8 +1777,8 @@ static int lpt_init_rd(struct ubifs_info *c)
|
|||
{
|
||||
int err, i;
|
||||
|
||||
c->ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
|
||||
c->lpt_lebs));
|
||||
c->ltab = vmalloc_array(c->lpt_lebs,
|
||||
sizeof(struct ubifs_lpt_lprops));
|
||||
if (!c->ltab)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -1846,8 +1846,8 @@ static int lpt_init_wr(struct ubifs_info *c)
|
|||
{
|
||||
int err, i;
|
||||
|
||||
c->ltab_cmt = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
|
||||
c->lpt_lebs));
|
||||
c->ltab_cmt = vmalloc_array(c->lpt_lebs,
|
||||
sizeof(struct ubifs_lpt_lprops));
|
||||
if (!c->ltab_cmt)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
|||
|
|
@ -1406,7 +1406,6 @@ static int fix_size_in_place(struct ubifs_info *c, struct size_entry *e)
|
|||
union ubifs_key key;
|
||||
int err, lnum, offs, len;
|
||||
loff_t i_size;
|
||||
uint32_t crc;
|
||||
|
||||
/* Locate the inode node LEB number and offset */
|
||||
ino_key_init(c, &key, e->inum);
|
||||
|
|
@ -1428,8 +1427,7 @@ static int fix_size_in_place(struct ubifs_info *c, struct size_entry *e)
|
|||
ino = c->sbuf + offs;
|
||||
ino->size = cpu_to_le64(e->d_size);
|
||||
len = le32_to_cpu(ino->ch.len);
|
||||
crc = crc32(UBIFS_CRC32_INIT, (void *)ino + 8, len - 8);
|
||||
ino->ch.crc = cpu_to_le32(crc);
|
||||
ubifs_crc_node((void *)ino, len);
|
||||
/* Work out where data in the LEB ends and free space begins */
|
||||
p = c->sbuf;
|
||||
len = c->leb_size - 1;
|
||||
|
|
|
|||
|
|
@ -321,7 +321,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
|
|||
c->fanout, znode->child_cnt);
|
||||
ubifs_err(c, "max levels %d, znode level %d",
|
||||
UBIFS_MAX_LEVELS, znode->level);
|
||||
err = 1;
|
||||
goto out_dump;
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +341,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
|
|||
zbr->lnum >= c->leb_cnt || zbr->offs < 0 ||
|
||||
zbr->offs + zbr->len > c->leb_size || zbr->offs & 7) {
|
||||
ubifs_err(c, "bad branch %d", i);
|
||||
err = 2;
|
||||
goto out_dump;
|
||||
}
|
||||
|
||||
|
|
@ -355,7 +353,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
|
|||
default:
|
||||
ubifs_err(c, "bad key type at slot %d: %d",
|
||||
i, key_type(c, &zbr->key));
|
||||
err = 3;
|
||||
goto out_dump;
|
||||
}
|
||||
|
||||
|
|
@ -368,7 +365,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
|
|||
ubifs_err(c, "bad target node (type %d) length (%d)",
|
||||
type, zbr->len);
|
||||
ubifs_err(c, "have to be %d", c->ranges[type].len);
|
||||
err = 4;
|
||||
goto out_dump;
|
||||
}
|
||||
} else if (zbr->len < c->ranges[type].min_len ||
|
||||
|
|
@ -378,7 +374,6 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
|
|||
ubifs_err(c, "have to be in range of %d-%d",
|
||||
c->ranges[type].min_len,
|
||||
c->ranges[type].max_len);
|
||||
err = 5;
|
||||
goto out_dump;
|
||||
}
|
||||
}
|
||||
|
|
@ -396,13 +391,11 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
|
|||
cmp = keys_cmp(c, key1, key2);
|
||||
if (cmp > 0) {
|
||||
ubifs_err(c, "bad key order (keys %d and %d)", i, i + 1);
|
||||
err = 6;
|
||||
goto out_dump;
|
||||
} else if (cmp == 0 && !is_hash_key(c, key1)) {
|
||||
/* These can only be keys with colliding hash */
|
||||
ubifs_err(c, "keys %d and %d are not hashed but equivalent",
|
||||
i, i + 1);
|
||||
err = 7;
|
||||
goto out_dump;
|
||||
}
|
||||
}
|
||||
|
|
@ -411,7 +404,7 @@ static int read_znode(struct ubifs_info *c, struct ubifs_zbranch *zzbr,
|
|||
return 0;
|
||||
|
||||
out_dump:
|
||||
ubifs_err(c, "bad indexing node at LEB %d:%d, error %d", lnum, offs, err);
|
||||
ubifs_err(c, "bad indexing node at LEB %d:%d", lnum, offs);
|
||||
ubifs_dump_node(c, idx, c->max_idx_node_sz);
|
||||
kfree(idx);
|
||||
return -EINVAL;
|
||||
|
|
|
|||
|
|
@ -1747,7 +1747,7 @@ int ubifs_write_node_hmac(struct ubifs_info *c, void *buf, int len, int lnum,
|
|||
int ubifs_check_node(const struct ubifs_info *c, const void *buf, int len,
|
||||
int lnum, int offs, int quiet, int must_chk_crc);
|
||||
void ubifs_init_node(struct ubifs_info *c, void *buf, int len, int pad);
|
||||
void ubifs_crc_node(struct ubifs_info *c, void *buf, int len);
|
||||
void ubifs_crc_node(void *buf, int len);
|
||||
void ubifs_prepare_node(struct ubifs_info *c, void *buf, int len, int pad);
|
||||
int ubifs_prepare_node_hmac(struct ubifs_info *c, void *node, int len,
|
||||
int hmac_offs, int pad);
|
||||
|
|
|
|||
Loading…
Reference in New Issue