From f7ab95ad975933059c34a6af589812d7962cf6a6 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 7 Jun 2022 00:44:04 +0200 Subject: [PATCH] dirvers/mtd: return early if init fails If init fails (e.g. because an SD card was not inserted) don't fail the `mtd->write_size != 0` assertion but instead return early. --- drivers/mtd/mtd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mtd/mtd.c b/drivers/mtd/mtd.c index 8d0d599d5a..4ce31bd667 100644 --- a/drivers/mtd/mtd.c +++ b/drivers/mtd/mtd.c @@ -38,6 +38,9 @@ int mtd_init(mtd_dev_t *mtd) if (mtd->driver->init) { res = mtd->driver->init(mtd); + if (res < 0) { + return res; + } } /* Drivers preceding the introduction of write_size need to set it. While