This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 79cab1c2e31 drivers/mtd: keep MTDIOC_ERASESECTORS inside its partition
79cab1c2e31 is described below

commit 79cab1c2e31cf812d4926dc20d31d75990dc954b
Author: Royyan Zahir <[email protected]>
AuthorDate: Wed Sep 30 12:16:53 2026 +0400

    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 <[email protected]>
---
 drivers/mtd/mtd_partition.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/mtd_partition.c b/drivers/mtd/mtd_partition.c
index b2fee01002b..f52c2a6bde7 100644
--- a/drivers/mtd/mtd_partition.c
+++ b/drivers/mtd/mtd_partition.c
@@ -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;
 

Reply via email to