From: Andrew Morton <akpm@linux-foundation.org>
To: Fabian Frederick <fabf@skynet.be>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
"fengguang.wu" <fengguang.wu@intel.com>,
"Chen, Jet" <jet.chen@intel.com>
Subject: Re: [PATCH linux-next v2] ufs: sb mutex merge + mutex_destroy: fix
Date: Fri, 28 Mar 2014 15:43:01 -0700 [thread overview]
Message-ID: <20140328154301.c25c495a8fcfd510ba2bf019@linux-foundation.org> (raw)
In-Reply-To: <20140327233831.c32f99a8fbabb31a5e37e598@skynet.be>
On Thu, 27 Mar 2014 23:38:31 +0100 Fabian Frederick <fabf@skynet.be> wrote:
> mutex_destroy was also called when trying to mount volume in read/write
> without write support enabled.
>
> --- a/fs/ufs/super.c
> +++ b/fs/ufs/super.c
> @@ -798,7 +798,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
> if (!(sb->s_flags & MS_RDONLY)) {
> printk("ufs was compiled with read-only support, "
> "can't be mounted as read-write\n");
> - goto failed;
> + goto failed_noreadwrite;
> }
> #endif
> mutex_init(&sbi->mutex);
> @@ -1255,10 +1255,14 @@ magic_found:
> return 0;
>
> failed:
> + mutex_destroy(&sbi->mutex);
> +
> +#ifndef CONFIG_UFS_FS_WRITE
> +failed_noreadwrite:
> +#endif
> if (ubh)
> ubh_brelse_uspi (uspi);
> kfree (uspi);
> - mutex_destroy(&sbi->mutex);
> kfree(sbi);
> sb->s_fs_info = NULL;
> UFSD("EXIT (FAILED)\n");
Ugly. Wht don't we perform the check before we've allocated anything
so we can simply return?
And it should return -EROFS, not -EINVAL.
--- a/fs/ufs/super.c~ufs-sb-mutex-merge-mutex_destroy-fix-v2-fix
+++ a/fs/ufs/super.c
@@ -785,6 +785,14 @@ static int ufs_fill_super(struct super_b
flags = 0;
UFSD("ENTER\n");
+
+#ifndef CONFIG_UFS_FS_WRITE
+ if (!(sb->s_flags & MS_RDONLY)) {
+ printk("ufs was compiled with read-only support, "
+ "can't be mounted as read-write\n");
+ return -EROFS;
+ }
+#endif
sbi = kzalloc(sizeof(struct ufs_sb_info), GFP_KERNEL);
if (!sbi)
@@ -794,13 +802,6 @@ static int ufs_fill_super(struct super_b
UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY));
-#ifndef CONFIG_UFS_FS_WRITE
- if (!(sb->s_flags & MS_RDONLY)) {
- printk("ufs was compiled with read-only support, "
- "can't be mounted as read-write\n");
- goto failed_noreadwrite;
- }
-#endif
mutex_init(&sbi->mutex);
spin_lock_init(&sbi->work_lock);
INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs);
@@ -1256,10 +1257,6 @@ magic_found:
failed:
mutex_destroy(&sbi->mutex);
-
-#ifndef CONFIG_UFS_FS_WRITE
-failed_noreadwrite:
-#endif
if (ubh)
ubh_brelse_uspi (uspi);
kfree (uspi);
_
prev parent reply other threads:[~2014-03-28 22:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-27 22:38 Fabian Frederick
2014-03-28 15:35 ` Chen, Jet
2014-03-28 22:43 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140328154301.c25c495a8fcfd510ba2bf019@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=fabf@skynet.be \
--cc=fengguang.wu@intel.com \
--cc=jet.chen@intel.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®