Skip to contentSkip to conversation

btrfs: allow mounting btrfs subvolumes with different ro/rw options

DISCUSSION Dan Carpenter 3 participants 4 messages Apr 14, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Hello Harald Hoyer,

The patch 0723a0473fb4: "btrfs: allow mounting btrfs subvolumes with different ro/rw options" from Nov 19, 2013, leads to the following static checker warning:

	fs/btrfs/super.c:1194 mount_subvol()
	warn: 'newargs' was already freed.

fs/btrfs/super.c
1177 static struct dentry *mount_subvol(const char *subvol_name, int flags,
1178 const char *device_name, char *data)
1179 {

  1180          struct dentry *root;
  1181          struct vfsmount *mnt;
  1182          char *newargs;
  1183  
  1184          newargs = setup_root_args(data);
  1185          if (!newargs)
  1186                  return ERR_PTR(-ENOMEM);
  1187          mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name,
  1188                               newargs);
  1189          kfree(newargs);
                      ^^^^^^^

Freed.

1190
1191 if (PTR_RET(mnt) == -EBUSY) {
1192 if (flags & MS_RDONLY) {
1193 mnt = vfs_kern_mount(&btrfs_fs_type, flags & ~MS_RDONLY, device_name,

  1194                                               newargs);
                                                     ^^^^^^^

Used if you have some security stuff enabled.

  1195                  } else {
  1196                          int r;
  1197                          mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name,
  1198                                               newargs);
                                                     ^^^^^^^
  1199                          if (IS_ERR(mnt))
  1200                                  return ERR_CAST(mnt);
  1201  
  1202                          r = btrfs_remount(mnt->mnt_sb, &flags, NULL);
  1203                          if (r < 0) {
  1204                                  /* FIXME: release vfsmount mnt ??*/
  1205                                  return ERR_PTR(r);
  1206                          }
  1207                  }
  1208          }
  1209  

Also you forgot to Sign your patch.

regards,
dan carpenter

#1 lore raw
Quoted 5 lines · Dan Carpenter

Hello Harald Hoyer,

The patch 0723a0473fb4: "btrfs: allow mounting btrfs subvolumes with different ro/rw options" from Nov 19, 2013, leads to the following static checker warning:

I'll fix this one up. Harald's email has changed and I should have pulled the patch in long ago.

Thanks Dan!

-chris

#2 lore raw
Quoted 11 lines · Chris Mason
Quoted 5 lines · Dan Carpenter

Hello Harald Hoyer,

The patch 0723a0473fb4: "btrfs: allow mounting btrfs subvolumes with different ro/rw options" from Nov 19, 2013, leads to the following static checker warning:

I'll fix this one up. Harald's email has changed and I should have pulled the patch in long ago.

There are now 2 reports for that and 1 patch,
https://patchwork.kernel.org/patch/3972911/

#3 lore raw
Quoted 10 lines · David Sterba
Quoted 9 lines · Chris Mason
Quoted 5 lines · Dan Carpenter

Hello Harald Hoyer,

The patch 0723a0473fb4: "btrfs: allow mounting btrfs subvolumes with different ro/rw options" from Nov 19, 2013, leads to the following static checker warning:

Quoted 5 lines
Quoted 2 lines

I'll fix this one up. Harald's email has changed and I should have pulled the patch in long ago.

There are now 2 reports for that and 1 patch,
https://patchwork.kernel.org/patch/3972911/

It was different static checkers though. Duplicate warnings are unavoidable in this situation.

regards,
dan carpenter