All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next v2] ufs: sb mutex merge + mutex_destroy: fix
@ 2014-03-27 22:38 Fabian Frederick
  2014-03-28 15:35 ` Chen, Jet
  2014-03-28 22:43 ` Andrew Morton
  0 siblings, 2 replies; 3+ messages in thread
From: Fabian Frederick @ 2014-03-27 22:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, fengguang.wu

mutex_destroy was also called when trying to mount volume in read/write
without write support enabled.

Reported by Fengguang Wu.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
v2: failed_noreadwrite is only used with CONFIG_UFS_FS_WRITE
    -> add ifndef

 fs/ufs/super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index d05cf89..432baa1 100644
--- 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");
-- 
1.8.4.5


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

* RE: [PATCH linux-next v2] ufs: sb mutex merge + mutex_destroy: fix
  2014-03-27 22:38 [PATCH linux-next v2] ufs: sb mutex merge + mutex_destroy: fix Fabian Frederick
@ 2014-03-28 15:35 ` Chen, Jet
  2014-03-28 22:43 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Chen, Jet @ 2014-03-28 15:35 UTC (permalink / raw)
  To: Fabian Frederick, linux-kernel; +Cc: akpm, Wu, Fengguang

Hi Fabian,

I helped to test your patch on our LKP system. Your patch fixes the boot failure issue. Thank you for your work.

Thanks,
-Jet 

-----Original Message-----
From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Fabian Frederick
Sent: Friday, March 28, 2014 6:39 AM
To: linux-kernel
Cc: akpm; Wu, Fengguang
Subject: [PATCH linux-next v2] ufs: sb mutex merge + mutex_destroy: fix

mutex_destroy was also called when trying to mount volume in read/write without write support enabled.

Reported by Fengguang Wu.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
v2: failed_noreadwrite is only used with CONFIG_UFS_FS_WRITE
    -> add ifndef

 fs/ufs/super.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ufs/super.c b/fs/ufs/super.c index d05cf89..432baa1 100644
--- 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");
--
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH linux-next v2] ufs: sb mutex merge + mutex_destroy: fix
  2014-03-27 22:38 [PATCH linux-next v2] ufs: sb mutex merge + mutex_destroy: fix Fabian Frederick
  2014-03-28 15:35 ` Chen, Jet
@ 2014-03-28 22:43 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2014-03-28 22:43 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, fengguang.wu, Chen, Jet

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);
_


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

end of thread, other threads:[~2014-03-28 22:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-27 22:38 [PATCH linux-next v2] ufs: sb mutex merge + mutex_destroy: fix Fabian Frederick
2014-03-28 15:35 ` Chen, Jet
2014-03-28 22:43 ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.