drivers/mtd: keep MTDIOC_ERASESECTORS inside its partition

The ioctl passed the erase to the parent unchecked, so an erase from the
last block on reached the next partition. part_erase() already bounds it.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
This commit is contained in:
Royyan Zahir 2026-09-30 12:16:53 +04:00 • committed by Xiang Xiao
parent dcc3b7b384
commit 79cab1c2e3

View file

@ -404,6 +404,7 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
case MTDIOC_GEOMETRY:
{
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)arg;
if (geo != NULL)
{
memcpy(geo, &priv->geo, sizeof(*geo));
@ -416,6 +417,7 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
{
FAR struct partition_info_s *info =
(FAR struct partition_info_s *)arg;
if (info != NULL)
{
info->numsectors = priv->geo.neraseblocks * priv->blkpererase;
@ -426,7 +428,7 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
sizeof(info->parent));
ret = OK;
}
}
}
break;
@ -470,10 +472,7 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
FAR struct mtd_erase_s *erase = (FAR struct mtd_erase_s *)arg;
ret = priv->parent->erase(priv->parent,
priv->firstblock / priv->blkpererase +
erase->startblock,
erase->nblocks);
ret = part_erase(dev, erase->startblock, erase->nblocks);
}
break;