Skip to content

Commit

Permalink
xtensa/esp32s3: partition name duplicate and free
Browse files Browse the repository at this point in the history
  • Loading branch information
sdc-g committed Aug 15, 2024
1 parent a409c42 commit 929e4e5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion arch/xtensa/src/esp32s3/esp32s3_partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,22 @@ int esp32s3_partition_init(void)
mtd_priv->mtd.ioctl = esp32s3_part_ioctl;
mtd_priv->mtd.read = esp32s3_part_read;
mtd_priv->mtd.write = esp32s3_part_write;
mtd_priv->mtd.name = label;
mtd_priv->mtd.name = strdup(label);
if (!mtd_priv->mtd.name)
{
ferr("ERROR: Failed to allocate MTD name\n");
kmm_free(mtd_priv);
ret = -ENOSPC;
goto errout_with_mtd;
}

mtd_priv->part_mtd = mtd_partition(&mtd_priv->mtd,
info->offset / geo.blocksize,
info->size / geo.blocksize);
if (!mtd_priv->part_mtd)
{
ferr("ERROR: Failed to create MTD partition\n");
lib_free(mtd_priv->mtd.name);
kmm_free(mtd_priv);
ret = -ENOSPC;
goto errout_with_mtd;
Expand All @@ -773,6 +781,7 @@ int esp32s3_partition_init(void)
if (ret < 0)
{
ferr("ERROR: Failed to register MTD @ %s\n", path);
lib_free(mtd_priv->mtd.name);
kmm_free(mtd_priv);
goto errout_with_mtd;
}
Expand Down

0 comments on commit 929e4e5

Please sign in to comment.