x1000: set the NAND driver's init guard so setup runs once
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 233ea05ea2b484fc797f6ed6992e8d2f02678840 Author: Michael McAllister <[email protected]> Date: Sun Aug 9 23:21:34 2026 +0100 x1000: set the NAND driver's init guard so setup runs once nand_init() guards its one-time setup with a static `inited` flag that nothing ever assigns, so every call re-runs the initialiser. That resets refcount to 0 on a driver another caller may already hold open, and the next nand_close() then decrements from zero and tears the driver down underneath its user. Assign the flag, and fix the caller that reaches this. On a failed open the installer's updater_cleanup() would call nand_close() against a driver nand_open() never took a reference on, because nand_open() only takes one once it has identified the chip; release the lock and drop the pointer instead. Change-Id: I88d54ac5bca9bcebb62fd9c6f50f1acf982a9a3b Co-Authored-By: Claude Opus 4.8 diff --git a/firmware/target/mips/ingenic_x1000/installer-x1000.c b/firmware/target/mips/ingenic_x1000/installer-x1000.c index 70ed270408..1b9ecf1f02 100644 --- a/firmware/target/mips/ingenic_x1000/installer-x1000.c +++ b/firmware/target/mips/ingenic_x1000/installer-x1000.c @@ -142,6 +142,8 @@ static int updater_init(struct updater* u) nand_lock(u->ndrv); rc = nand_open(u->ndrv); if(rc != NAND_SUCCESS) { + nand_unlock(u->ndrv); + u->ndrv = NULL; rc = IERR_NAND_OPEN; goto error; } diff --git a/firmware/target/mips/ingenic_x1000/nand-x1000.c b/firmware/target/mips/ingenic_x1000/nand-x1000.c index 39e06b1964..6961cbe58a 100644 --- a/firmware/target/mips/ingenic_x1000/nand-x1000.c +++ b/firmware/target/mips/ingenic_x1000/nand-x1000.c @@ -143,6 +143,7 @@ struct nand_drv* nand_init(void) static_nand_drv.scratch_buf = static_scratch_buf; static_nand_drv.page_buf = static_page_buf; static_nand_drv.refcount = 0; + inited = true; } return &static_nand_drv; -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs