[PATCH v2 2/3] mtd: maps: vmu-flash: fix fault in unaligned fixup

Florian Fuchs
2026-04-27T11:51:19Z

Use kzalloc_obj() / kzalloc_objs() to allocate the memcard structs,
instead of kmalloc_obj() / kmalloc_objs() to prevent access to
uninitialized data.

Fixes runtime error: Fault in unaligned fixup: 0000 [#1] at
mtd_get_fact_prot_info.

Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
---
v1->v2: no functional change, just rebased.

v1: https://lore.kernel.org/lkml/20251117224408.498449-3-fuchsfl@gmail.com/

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 75e06d249ce9..b76d0609d1b7 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_obj(struct memcard);
+ card = kzalloc_obj(struct memcard);
if (!card) {
error = -ENOMEM;
goto fail_nomem;
@@ -627,13 +627,13 @@ 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_objs(struct vmupart, card->partitions);
+ card->parts = kzalloc_objs(struct vmupart, card->partitions);
if (!card->parts) {
error = -ENOMEM;
goto fail_partitions;
}

- card->mtd = kmalloc_objs(struct mtd_info, card->partitions);
+ card->mtd = kzalloc_objs(struct mtd_info, card->partitions);
if (!card->mtd) {
error = -ENOMEM;
goto fail_mtd_info;
--
2.43.0