[Devel] [PATCH RHEL7 COMMIT] binfmt_misc: don't free per-VE object on error path

Vasily Averin vvs at virtuozzo.com
Tue Oct 26 14:26:30 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.42.2.vz7.184.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.42.2.vz7.184.2
------>
commit e9f426506825628dc398bc8e9530cf14094889f8
Author: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
Date:   Tue Oct 26 14:26:30 2021 +0300

    binfmt_misc: don't free per-VE object on error path
    
    Freeing bm_data on mount error path is wrong because it could be
    allocated on older mount and store valid data.
    
    The object will be freed at ve destruction time.
    
    Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
    
    Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 fs/binfmt_misc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 75cc8c2..8b6665b 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -722,13 +722,12 @@ static int bm_fill_super(struct super_block * sb, void * data, int silent)
 		rwlock_init(&bm_data->entries_lock);
 
 		ve->binfmt_misc = bm_data;
+		/* this will be freed in ve_destroy() */
 	}
 
 	err = simple_fill_super(sb, BINFMTFS_MAGIC, bm_files);
-	if (err) {
-		kfree(bm_data);
+	if (err)
 		return err;
-	}
 
 	sb->s_op = &s_ops;
 


More information about the Devel mailing list