From: JiSheng Zhang <jszhang3@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: Artem.Bityutskiy@nokia.com, dwmw2@infradead.org,
linux-kernel@vger.kernel.org, rmk@arm.linux.org.uk,
adrian.hunter@nokia.com
Subject: [PATCH] UBI: Fix allocation of volume table
Date: Tue, 11 Aug 2009 09:25:24 +0800 [thread overview]
Message-ID: <20090811092524.12e4494b@ustc> (raw)
We can't use vmalloc for the buffer used for volume table for some NAND
or NOR drivers may pass the buffer to DMA. And the volume table size
a.k.a vtbl_size is small so we can use kmalloc or kzalloc for it instead.
Signed-off-by: JiSheng Zhang <jszhang3@gmail.com>
---
drivers/mtd/ubi/vtbl.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 1afc61e..9dcc7ba 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -424,12 +424,11 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
/* Read both LEB 0 and LEB 1 into memory */
ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) {
- leb[seb->lnum] = vmalloc(ubi->vtbl_size);
+ leb[seb->lnum] = kzalloc(ubi->vtbl_size, GFP_KERNEL);
if (!leb[seb->lnum]) {
err = -ENOMEM;
goto out_free;
}
- memset(leb[seb->lnum], 0, ubi->vtbl_size);
err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0,
ubi->vtbl_size);
@@ -515,10 +514,9 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
int i;
struct ubi_vtbl_record *vtbl;
- vtbl = vmalloc(ubi->vtbl_size);
+ vtbl = kzalloc(ubi->vtbl_size, GFP_KERNEL);
if (!vtbl)
return ERR_PTR(-ENOMEM);
- memset(vtbl, 0, ubi->vtbl_size);
for (i = 0; i < ubi->vtbl_slots; i++)
memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE);
--
1.6.3.3
next reply other threads:[~2009-08-11 1:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-11 1:25 JiSheng Zhang [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-08-11 1:44 [PATCH] UBI: Fix allocation of volume table JiSheng Zhang
2009-08-14 16:05 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090811092524.12e4494b@ustc \
--to=jszhang3@gmail.com \
--cc=Artem.Bityutskiy@nokia.com \
--cc=adrian.hunter@nokia.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=rmk@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).