Skip to content

Commit 0192883

Browse files
foxdroddgregkh
authored andcommitted
mtd: maps: vmu-flash: fix fault in unaligned fixup
[ Upstream commit 79d1661 ] 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: 47a7268 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6cf9a80 commit 0192883

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

drivers/mtd/maps/vmu-flash.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static int vmu_connect(struct maple_device *mdev)
610610

611611
basic_flash_data = be32_to_cpu(mdev->devinfo.function_data[c - 1]);
612612

613-
card = kmalloc(sizeof(struct memcard), GFP_KERNEL);
613+
card = kzalloc_obj(struct memcard);
614614
if (!card) {
615615
error = -ENOMEM;
616616
goto fail_nomem;
@@ -628,15 +628,13 @@ static int vmu_connect(struct maple_device *mdev)
628628
* Not sure there are actually any multi-partition devices in the
629629
* real world, but the hardware supports them, so, so will we
630630
*/
631-
card->parts = kmalloc_array(card->partitions, sizeof(struct vmupart),
632-
GFP_KERNEL);
631+
card->parts = kzalloc_objs(struct vmupart, card->partitions);
633632
if (!card->parts) {
634633
error = -ENOMEM;
635634
goto fail_partitions;
636635
}
637636

638-
card->mtd = kmalloc_array(card->partitions, sizeof(struct mtd_info),
639-
GFP_KERNEL);
637+
card->mtd = kzalloc_objs(struct mtd_info, card->partitions);
640638
if (!card->mtd) {
641639
error = -ENOMEM;
642640
goto fail_mtd_info;

0 commit comments

Comments
 (0)