Re: [PATCH v2] mtd: take a reference when opening an unpartitioned master

From: Miquel Raynal

Date: Fri Dec 04 2026 - 16:37:58 EST


On 20/11/2026 at 09:01:35 -07, James Hilliard <james.hilliard1@xxxxxxxxx> wrote:

> With CONFIG_MTD_PARTITIONED_MASTER disabled, a flash device with no
> partitions still gets a /dev/mtdX node. Opening that node does not take
> a reference on the master MTD. If the driver unregisters the flash
> before the file is closed, the core can unregister the MTD device and
> its NVMEM provider while the file is still open.
>
> Take a master reference for a handle on the master and drop it when the
> handle is released. A handle on a partition still takes a master
> reference only when CONFIG_MTD_PARTITIONED_MASTER is enabled.
>
> Fixes: 264725e35fbc ("mtd: Clean refcounting with MTD_PARTITIONED_MASTER")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>

Guess what, doesn't apply either.