]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mtd: maps: vmu-flash: fix fault in unaligned fixup
authorFlorian Fuchs <fuchsfl@gmail.com>
Mon, 18 May 2026 11:45:20 +0000 (13:45 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 27 May 2026 09:07:59 +0000 (11:07 +0200)
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.

Fixes: 47a72688fae7 ("mtd: flash mapping support for Dreamcast VMU.")
Cc: stable@vger.kernel.org
Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/maps/vmu-flash.c

index 75e06d249ce9956e4e083f3f8b3f4d6a461da045..b76d0609d1b76b036dc77ca763b11cc18b8e3bf1 100644 (file)
@@ -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;