Skip to content

Commit

Permalink
[UBI] drivers/mtd/ubi/scan.c: kmalloc + memset conversion to kzalloc
Browse files Browse the repository at this point in the history
To be able to convert kmalloc + memset(..., 1, ...) to kzalloc this patch
reverses the logic around 'buf'.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
Mariusz Kozlowski authored and David Woodhouse committed Aug 1, 2007
1 parent 4fb4caa commit d9b0744
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions drivers/mtd/ubi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1314,40 +1314,39 @@ static int paranoid_check_si(const struct ubi_device *ubi,
* Make sure that all the physical eraseblocks are in one of the lists
* or trees.
*/
buf = kmalloc(ubi->peb_count, GFP_KERNEL);
buf = kzalloc(ubi->peb_count, GFP_KERNEL);
if (!buf)
return -ENOMEM;

memset(buf, 1, ubi->peb_count);
for (pnum = 0; pnum < ubi->peb_count; pnum++) {
err = ubi_io_is_bad(ubi, pnum);
if (err < 0) {
kfree(buf);
return err;
}
else if (err)
buf[pnum] = 0;
buf[pnum] = 1;
}

ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb)
ubi_rb_for_each_entry(rb2, seb, &sv->root, u.rb)
buf[seb->pnum] = 0;
buf[seb->pnum] = 1;

list_for_each_entry(seb, &si->free, u.list)
buf[seb->pnum] = 0;
buf[seb->pnum] = 1;

list_for_each_entry(seb, &si->corr, u.list)
buf[seb->pnum] = 0;
buf[seb->pnum] = 1;

list_for_each_entry(seb, &si->erase, u.list)
buf[seb->pnum] = 0;
buf[seb->pnum] = 1;

list_for_each_entry(seb, &si->alien, u.list)
buf[seb->pnum] = 0;
buf[seb->pnum] = 1;

err = 0;
for (pnum = 0; pnum < ubi->peb_count; pnum++)
if (buf[pnum]) {
if (!buf[pnum]) {
ubi_err("PEB %d is not referred", pnum);
err = 1;
}
Expand Down

0 comments on commit d9b0744

Please sign in to comment.