From 0aeacade023e7ef16faa97906f72b9c6455d99e2 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Thu, 8 Feb 2018 13:21:51 +0000 Subject: [PATCH] Decrease refcount when unmounting fs CL: none PUBLISHED_FROM=1cfba23a55311663b645a6051ef877ad46338814 --- fw/src/mgos_vfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fw/src/mgos_vfs.c b/fw/src/mgos_vfs.c index 73fee1b58..6b6d52baf 100644 --- a/fw/src/mgos_vfs.c +++ b/fw/src/mgos_vfs.c @@ -82,7 +82,6 @@ bool mgos_vfs_mkfs(const char *dev_type, const char *dev_opts, if (dev_type != NULL) { dev = mgos_vfs_dev_open(dev_type, dev_opts); if (dev == NULL) return false; - dev->refs++; } struct mgos_vfs_fs fs = {.type = fe->type, .ops = fe->ops, .dev = dev}; LOG(LL_INFO, ("Create %s (dev %p, opts %s)", fs_type, dev, fs_opts)); @@ -902,7 +901,10 @@ static bool mgos_vfs_umount_entry(struct mgos_vfs_mount_entry *me, bool force) { SLIST_REMOVE(&s_mounts, me, mgos_vfs_mount_entry, next); ret = me->fs->ops->umount(me->fs); if (ret) { - if (me->fs->dev) mgos_vfs_dev_close(me->fs->dev); + if (me->fs->dev) { + me->fs->dev->refs--; + mgos_vfs_dev_close(me->fs->dev); + } free(me->fs); free(me); }