[Ocfs2-tools-devel] [PATCH V1] mount.ocfs2: Fix double free problems when remounting a device
Joseph Qi
jiangqi903 at gmail.com
Sun Feb 11 17:04:55 PST 2018
On 18/2/11 20:39, Shichangkuo wrote:
> From 60985d3705d401427c5db4116716fc5bc5223662 Mon Sep 17 00:00:00 2001
> From: shichangkuo <shi.changkuo at h3c.com>
> Date: Wed, 7 Feb 2018 17:25:08 +0800
> Subject: [PATCH] mount.ocfs2: Fix double free problems when remounting a
> device
>
The above should be eliminated in your patch body.
> When remounting a device, the issue happens:
> ~# mount -o remount,rw /vms/share
> *** Error in `/sbin/mount.ocfs2': double free or corruption (!prev): 0x0000000000b305a0
> *** Aborted
>
> When updating the mtab, we should free the old mnt_opts, and duplicate
> a new one from instead->mnt_opts.
>
> Signed-off-by: shichangkuo <shi.changkuo at h3c.com>
> ---
> mount.ocfs2/fstab.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mount.ocfs2/fstab.c b/mount.ocfs2/fstab.c
> index d3fc617..59cd369 100644
> --- a/mount.ocfs2/fstab.c
> +++ b/mount.ocfs2/fstab.c
> @@ -612,7 +612,8 @@ update_mtab (const char *dir, struct my_mntent *instead) {
> }
> } else {
> /* A remount */
> - mc->m.mnt_opts = instead->mnt_opts;
> + my_free(mc->m.mnt_opts);
Why we have to free here?
Thanks,
Joseph
> + mc->m.mnt_opts = xstrdup(instead->mnt_opts);
> }
> } else if (instead) {
> /* not found, add a new entry */
> --
> 1.7.9.5
More information about the Ocfs2-tools-devel
mailing list