<p>The memory allocated for multiple devices should be freed when to exit.
<br>Let's add a helper to fix it since there is more than one to use it.
<br>
<br>Signed-off-by: Yue Hu <huyue2@coolpad.com>
<br>---
<br> dump/main.c              | 7 ++++---
<br> fsck/main.c              | 7 ++++---
<br> fuse/main.c              | 5 +++--
<br> include/erofs/internal.h | 1 +
<br> lib/super.c              | 6 ++++++
<br> 5 files changed, 18 insertions(+), 8 deletions(-)
<br>
<br>diff --git a/dump/main.c b/dump/main.c
<br>index 40e850a..c9b3a8f 100644
<br>--- a/dump/main.c
<br>+++ b/dump/main.c
<br>@@ -615,7 +615,7 @@ int main(int argc, char **argv)
<br>      err = erofs_read_superblock();
<br>      if (err) {
<br>              erofs_err("failed to read superblock");
<br>-             goto exit_dev_close;
<br>+             goto exit_put_super;
<br>      }
<br> 
<br>      if (!dumpcfg.totalshow) {
<br>@@ -630,13 +630,14 @@ int main(int argc, char **argv)
<br> 
<br>      if (dumpcfg.show_extent && !dumpcfg.show_inode) {
<br>              usage();
<br>-             goto exit_dev_close;
<br>+             goto exit_put_super;
<br>      }
<br> 
<br>      if (dumpcfg.show_inode)
<br>              erofsdump_show_fileinfo(dumpcfg.show_extent);
<br> 
<br>-exit_dev_close:
<br>+exit_put_super:
<br>+     erofs_put_super();
<br>      dev_close();
<br> exit:
<br>      blob_closeall();
<br>diff --git a/fsck/main.c b/fsck/main.c
<br>index 5a2f659..a8f0e24 100644
<br>--- a/fsck/main.c
<br>+++ b/fsck/main.c
<br>@@ -813,12 +813,12 @@ int main(int argc, char **argv)
<br>      err = erofs_read_superblock();
<br>      if (err) {
<br>              erofs_err("failed to read superblock");
<br>-             goto exit_dev_close;
<br>+             goto exit_put_super;
<br>      }
<br> 
<br>      if (erofs_sb_has_sb_chksum() && erofs_check_sb_chksum()) {
<br>              erofs_err("failed to verify superblock checksum");
<br>-             goto exit_dev_close;
<br>+             goto exit_put_super;
<br>      }
<br> 
<br>      err = erofsfsck_check_inode(sbi.root_nid, sbi.root_nid);
<br>@@ -843,7 +843,8 @@ int main(int argc, char **argv)
<br>              }
<br>      }
<br> 
<br>-exit_dev_close:
<br>+exit_put_super:
<br>+     erofs_put_super();
<br>      dev_close();
<br> exit:
<br>      blob_closeall();
<br>diff --git a/fuse/main.c b/fuse/main.c
<br>index 95f939e..95f7abc 100644
<br>--- a/fuse/main.c
<br>+++ b/fuse/main.c
<br>@@ -295,11 +295,12 @@ int main(int argc, char *argv[])
<br>      ret = erofs_read_superblock();
<br>      if (ret) {
<br>              fprintf(stderr, "failed to read erofs super block\n");
<br>-             goto err_dev_close;
<br>+             goto err_put_super;
<br>      }
<br> 
<br>      ret = fuse_main(args.argc, args.argv, &erofs_ops, NULL);
<br>-err_dev_close:
<br>+err_put_super:
<br>+     erofs_put_super();
<br>      blob_closeall();
<br>      dev_close();
<br> err_fuse_free_args:
<br>diff --git a/include/erofs/internal.h b/include/erofs/internal.h
<br>index 6a70f11..48498fe 100644
<br>--- a/include/erofs/internal.h
<br>+++ b/include/erofs/internal.h
<br>@@ -318,6 +318,7 @@ struct erofs_map_dev {
<br> 
<br> /* super.c */
<br> int erofs_read_superblock(void);
<br>+void erofs_put_super(void);
<br> 
<br> /* namei.c */
<br> int erofs_read_inode_from_disk(struct erofs_inode *vi);
<br>diff --git a/lib/super.c b/lib/super.c
<br>index f486eb7..913d2fb 100644
<br>--- a/lib/super.c
<br>+++ b/lib/super.c
<br>@@ -109,3 +109,9 @@ int erofs_read_superblock(void)
<br>      memcpy(&sbi.uuid, dsb->uuid, sizeof(dsb->uuid));
<br>      return erofs_init_devices(&sbi, dsb);
<br> }
<br>+
<br>+void erofs_put_super(void)
<br>+{
<br>+     if (sbi.devs)
<br>+             free(sbi.devs);
<br>+}
<br>-- 
<br>2.17.1</p><meta data-version="editor_version_1.2.11"/><div data-zone-id="0" data-line-index="0" data-line="true" style="white-space: pre-wrap; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">------机密:此电子邮件所包含内容为酷派机密内容,并且受到法律的保护。如果您不属于以上电子邮件的目标接收者,您不得细读,使用,传播,散布或复制该电子邮件中的任何信息。如果您已经误收此电子邮件,请您立即通知我们并删除原电子邮件。 CONFIDENTIAL: This e-mail message contains information of Coolpad that is confidential and which is subject to legal privilege.If you are not the intended recipient as indicated above,you must not peruse,use, disseminate,distribute or copy any information contained in this message.If you have received this message in error, please notify us and delete the original message immediately.
</div><div data-zone-id="0" data-line-index="1" data-line="true" style="white-space: pre-wrap; margin-top: 4px; margin-bottom: 4px; line-height: 1.6;">------ 申明:本邮件所现内容,仅作为我们之间就合作的事宜进行的交流、沟通、洽谈、商议,不作为协议或承诺,一切协议及承诺必须以书面文本盖章为准。 DECLARATION:All contents of this E-mail ,are only regarded as the cooperation we have had between the exchanges, communication, negotiation and deliberation, not as a agreement or promise. All contracts and commitments must be  sealed shall prevail.
</div>