* [PATCH v3 1/3] maple: fix build error due to missing include of linux/device.h
2026-05-18 11:45 [PATCH v3 0/3] mtd: maps: vmu-flash: Fix build and runtime errors Florian Fuchs
@ 2026-05-18 11:45 ` Florian Fuchs
2026-05-18 11:45 ` [PATCH v3 2/3] mtd: maps: vmu-flash: fix fault in unaligned fixup Florian Fuchs
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Florian Fuchs @ 2026-05-18 11:45 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, linux-mtd
Cc: linux-sh, linux-kernel, Rich Felker, John Paul Adrian Glaubitz,
Adrian McMenamin, Florian Fuchs, Artur Rojek
The commit 313162d0b838 ("device.h: audit and cleanup users in main
include dir") removed the include linux/device.h from linux/maple.h,
which led to build errors as linux/maple.h embeds struct device via
struct maple_device. So restore this, as it otherwise results in errors:
./include/linux/maple.h:81:16: error: field 'dev' has incomplete type
struct device dev;
Fixes: 313162d0b838 ("device.h: audit and cleanup users in main include dir")
Cc: stable@vger.kernel.org
Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
---
v2->v3: no functional change, reword commit message, align subject to
main includedir, add Cc tag
v1->v2: no functional change, just rebase patch
v2: https://lore.kernel.org/lkml/20260427114750.2480900-2-fuchsfl@gmail.com/
v1: https://lore.kernel.org/lkml/20251117224408.498449-2-fuchsfl@gmail.com/
include/linux/maple.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/linux/maple.h b/include/linux/maple.h
index 3be4e567473c..22f2930251ed 100644
--- a/include/linux/maple.h
+++ b/include/linux/maple.h
@@ -2,10 +2,9 @@
#ifndef __LINUX_MAPLE_H
#define __LINUX_MAPLE_H
+#include <linux/device.h>
#include <mach/maple.h>
-struct device;
-
/* Maple Bus command and response codes */
enum maple_code {
MAPLE_RESPONSE_FILEERR = -5,
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v3 2/3] mtd: maps: vmu-flash: fix fault in unaligned fixup
2026-05-18 11:45 [PATCH v3 0/3] mtd: maps: vmu-flash: Fix build and runtime errors Florian Fuchs
2026-05-18 11:45 ` [PATCH v3 1/3] maple: fix build error due to missing include of linux/device.h Florian Fuchs
@ 2026-05-18 11:45 ` Florian Fuchs
2026-05-18 11:45 ` [PATCH v3 3/3] mtd: maps: vmu-flash: fix NULL pointer dereference in initialization Florian Fuchs
2026-05-18 12:06 ` [PATCH v3 0/3] mtd: maps: vmu-flash: Fix build and runtime errors Miquel Raynal
3 siblings, 0 replies; 5+ messages in thread
From: Florian Fuchs @ 2026-05-18 11:45 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, linux-mtd
Cc: linux-sh, linux-kernel, Rich Felker, John Paul Adrian Glaubitz,
Adrian McMenamin, Florian Fuchs, Artur Rojek
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>
---
v2->v3: no functional change, add Fixes, Cc tag according to feedback
v1->v2: no functional change, just rebased.
v2: https://lore.kernel.org/lkml/20260427114750.2480900-3-fuchsfl@gmail.com/
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
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v3 3/3] mtd: maps: vmu-flash: fix NULL pointer dereference in initialization
2026-05-18 11:45 [PATCH v3 0/3] mtd: maps: vmu-flash: Fix build and runtime errors Florian Fuchs
2026-05-18 11:45 ` [PATCH v3 1/3] maple: fix build error due to missing include of linux/device.h Florian Fuchs
2026-05-18 11:45 ` [PATCH v3 2/3] mtd: maps: vmu-flash: fix fault in unaligned fixup Florian Fuchs
@ 2026-05-18 11:45 ` Florian Fuchs
2026-05-18 12:06 ` [PATCH v3 0/3] mtd: maps: vmu-flash: Fix build and runtime errors Miquel Raynal
3 siblings, 0 replies; 5+ messages in thread
From: Florian Fuchs @ 2026-05-18 11:45 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra, linux-mtd
Cc: linux-sh, linux-kernel, Rich Felker, John Paul Adrian Glaubitz,
Adrian McMenamin, Florian Fuchs, Artur Rojek
The mtd_info contains a struct device, which must be linked to its
parent. Without this, the initialization of the MTD fails with a NULL
pointer dereference.
Fixes: 47a72688fae7 ("mtd: flash mapping support for Dreamcast VMU.")
Cc: stable@vger.kernel.org
Signed-off-by: Florian Fuchs <fuchsfl@gmail.com>
---
v2->v3: no functional change, added Fixes, Cc tag according to feedback
v1->v2: no functional change
v2: https://lore.kernel.org/lkml/20260427114750.2480900-4-fuchsfl@gmail.com/
v1: https://lore.kernel.org/lkml/20251117224408.498449-4-fuchsfl@gmail.com/
drivers/mtd/maps/vmu-flash.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/maps/vmu-flash.c b/drivers/mtd/maps/vmu-flash.c
index b76d0609d1b7..10244e6731d0 100644
--- a/drivers/mtd/maps/vmu-flash.c
+++ b/drivers/mtd/maps/vmu-flash.c
@@ -547,6 +547,7 @@ static void vmu_queryblocks(struct mapleq *mq)
mpart->partition = card->partition;
mtd_cur->priv = mpart;
mtd_cur->owner = THIS_MODULE;
+ mtd_cur->dev.parent = &mdev->dev;
pcache = kzalloc_obj(struct vmu_cache);
if (!pcache)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v3 0/3] mtd: maps: vmu-flash: Fix build and runtime errors
2026-05-18 11:45 [PATCH v3 0/3] mtd: maps: vmu-flash: Fix build and runtime errors Florian Fuchs
` (2 preceding siblings ...)
2026-05-18 11:45 ` [PATCH v3 3/3] mtd: maps: vmu-flash: fix NULL pointer dereference in initialization Florian Fuchs
@ 2026-05-18 12:06 ` Miquel Raynal
3 siblings, 0 replies; 5+ messages in thread
From: Miquel Raynal @ 2026-05-18 12:06 UTC (permalink / raw)
To: Florian Fuchs
Cc: Richard Weinberger, Vignesh Raghavendra, linux-mtd, linux-sh,
linux-kernel, Rich Felker, John Paul Adrian Glaubitz,
Adrian McMenamin, Artur Rojek
Hi Florian,
On 18/05/2026 at 13:45:18 +02, Florian Fuchs <fuchsfl@gmail.com> wrote:
> Hi all,
>
> This small series fixes build and runtime errors in the vmu-flash driver
> (enabled by CONFIG_MTD_VMU) and the related maple.h. These changes were
> verified on real Dreamcast hardware with a physical VMU. The VMU can now
> be successfully probed, read and written with MTD tools like mtdinfo and
> mtd_debug. Previously, the driver failed to build or crashed during
> probing.
>
> bash-5.3# mtdinfo /dev/mtd0
> mtd0
> Name: vmu2.1.0
> Type: mlc-nand
> Eraseblock size: 512 bytes
> Amount of eraseblocks: 256 (131072 bytes, 128.0 KiB)
> Minimum input/output unit size: 512 bytes
> Sub-page size: 512 bytes
> Character device major/minor: 90:0
> Bad blocks are allowed: true
> Device is writable: true
>
> Thanks,
> Florian
> ---
I believe there is no issue in applying patches 2 and 3 on top of the
mtd tree and let whoever is responsible take patch 1. If I get an ack I
can also carry patch 1 through the mtd tree. Without more feedback I
plan on applying patches 2 and 3 in the coming weeks.
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 5+ messages in thread