[PATCH 2/3] mtd: maps: vmu-flash: Fix fault in unaligned fixup
Florian Fuchs <[email protected]>
| Newsgroups | gmane.linux.ports.sh.devel,gmane.linux.drivers.mtd,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
Use kcalloc() / kzalloc() to allocate the memcard structs, instead of kmalloc() / kmalloc_array() to prevent access to uninitialized data. This fixes runtime error: Fault in unaligned fixup: 0000 [#1] at mtd_get_fact_prot_info. Signed-off-by: Florian Fuchs <[email protected]> --- drivers/mtd/maps/vmu-flash.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/maps/vmu-flash.c b/drivers/mtd/maps/vmu-flash.c index 53019d313db7..d0793f1b0fac 100644 --- a/drivers/mtd/maps/vmu-flash.c +++ b/drivers/mtd/maps/vmu-flash.c @@ -609,7 +609,7 @@ static int vmu_connect(struct maple_device *mdev) basic_flash_data = be32_to_cpu(mdev->devinfo.function_data[c - 1]); - card = kmalloc(sizeof(struct memcard), GFP_KERNEL); + card = kzalloc(sizeof(struct memcard), GFP_KERNEL); if (!card) { error = -ENOMEM; goto fail_nomem; @@ -627,14 +627,14 @@ static int vmu_connect(struct maple_device *mdev) * Not sure there are actually any multi-partition devices in the * real world, but the hardware supports them, so, so will we */ - card->parts = kmalloc_array(card->partitions, sizeof(struct vmupart), + card->parts = kcalloc(card->partitions, sizeof(struct vmupart), GFP_KERNEL); if (!card->parts) { error = -ENOMEM; goto fail_partitions; } - card->mtd = kmalloc_array(card->partitions, sizeof(struct mtd_info), + card->mtd = kcalloc(card->partitions, sizeof(struct mtd_info), GFP_KERNEL); if (!card->mtd) { error = -ENOMEM; -- 2.43.0