summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2019-10-29 12:39:50 +0000
committerJohn Crispin <john@phrozen.org>2019-11-02 19:23:23 +0100
commit2f2a09adbc148d7958be66b00b68ab0609043523 (patch)
tree52a6e17f5dc56b746888753238dce21fdeb529e0
parentda4edc12ec9b647331a7491e3dbb963b453645da (diff)
downloadfstools-2f2a09adbc148d7958be66b00b68ab0609043523.tar.gz
block: mount_device: err log only when mp deviates from spec
Fixes possible memleak of mp as well Resolves FS#1523 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r--block.c10
1 files changed, 7 insertions, 3 deletions
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)