diff mbox series

[OpenWrt-Devel,fstools,5/5] block: mount_device: err log only when mp deviates from spec

Message ID 20191029123950.40794-5-yszhou4tech@gmail.com
State Accepted
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel,fstools,1/5] block: umount: skip / unless -a is given | expand

Commit Message

Yousong Zhou Oct. 29, 2019, 12:39 p.m. UTC
Fixes possible memleak of mp as well

Resolves FS#1523

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
 block.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/block.c b/block.c
index 084e7fc..1972c50 100644
--- a/block.c
+++ b/block.c
@@ -1092,10 +1092,14 @@  static int mount_device(struct device *dev, int type)
 		return -1;
 
 	mp = find_mount_point(pr->dev);
-	if (mp && (type != TYPE_HOTPLUG)) {
-		ULOG_ERR("%s is already mounted on %s\n", pr->dev, mp);
+	if (mp) {
+		if (m && m->type == TYPE_MOUNT && strcmp(m->target, mp)) {
+			ULOG_ERR("%s is already mounted on %s\n", pr->dev, mp);
+			err = -1;
+		} else
+			err = 0;
 		free(mp);
-		return -1;
+		return err;
 	}
 
 	if (type == TYPE_HOTPLUG)