linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: btrfs: allow mounting btrfs subvolumes with different ro/rw options
@ 2014-04-14 13:10 Dan Carpenter
  2014-04-14 13:39 ` Chris Mason
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2014-04-14 13:10 UTC (permalink / raw)
  To: harald; +Cc: linux-btrfs

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-14 17:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-14 13:10 btrfs: allow mounting btrfs subvolumes with different ro/rw options Dan Carpenter
2014-04-14 13:39 ` Chris Mason
2014-04-14 16:17   ` David Sterba
2014-04-14 17:08     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).