From: Florian Fuchs <fuchsfl@gmail.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-mtd@lists.infradead.org
Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org,
Rich Felker <dalias@libc.org>,
John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
Florian Fuchs <fuchsfl@gmail.com>
Subject: [PATCH 2/3] mtd: maps: vmu-flash: Fix fault in unaligned fixup
Date: Mon, 17 Nov 2025 23:44:07 +0100 [thread overview]
Message-ID: <20251117224408.498449-3-fuchsfl@gmail.com> (raw)
In-Reply-To: <20251117224408.498449-1-fuchsfl@gmail.com>
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 <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 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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2025-11-17 22:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 22:44 [PATCH 0/3] mtd: maps: vmu-flash: Fix build and runtime errors Florian Fuchs
2025-11-17 22:44 ` [PATCH 1/3] sh: maple: Fix build error due to missing include of linux/device.h Florian Fuchs
2025-11-17 22:44 ` Florian Fuchs [this message]
2025-11-17 22:44 ` [PATCH 3/3] mtd: maps: vmu-flash: Fix NULL pointer dereference in initialization Florian Fuchs
2025-11-18 7:31 ` [PATCH 0/3] mtd: maps: vmu-flash: Fix build and runtime errors John Paul Adrian Glaubitz
2025-11-19 21:36 ` Artur Rojek
2025-11-19 21:44 ` Florian Fuchs
2025-11-19 21:54 ` Artur Rojek
2025-11-20 8:52 ` Florian Fuchs
2025-11-20 9:09 ` John Paul Adrian Glaubitz
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=20251117224408.498449-3-fuchsfl@gmail.com \
--to=fuchsfl@gmail.com \
--cc=dalias@libc.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-sh@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
/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