All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: erofs: fix potential double iput in erofs_read_super()
@ 2019-01-23  6:12 Chengguang Xu
  2019-01-23 13:46 ` Gao Xiang
  2019-01-24  8:46 ` Chao Yu
  0 siblings, 2 replies; 3+ messages in thread
From: Chengguang Xu @ 2019-01-23  6:12 UTC (permalink / raw)


Some error cases like failing from d_make_root() will
cause double iput because d_make_root() also does iput
in its error path.

Signed-off-by: Chengguang Xu <cgxu519 at gmx.com>
---
Only compile tested.

 drivers/staging/erofs/super.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
index 1c2eb69682ef..bd97679aacfc 100644
--- a/drivers/staging/erofs/super.c
+++ b/drivers/staging/erofs/super.c
@@ -420,13 +420,14 @@ static int erofs_read_super(struct super_block *sb,
 		errln("rootino(nid %llu) is not a directory(i_mode %o)",
 			ROOT_NID(sbi), inode->i_mode);
 		err = -EINVAL;
-		goto err_isdir;
+		iput(inode);
+		goto err_iget;
 	}
 
 	sb->s_root = d_make_root(inode);
 	if (sb->s_root == NULL) {
 		err = -ENOMEM;
-		goto err_makeroot;
+		goto err_iget;
 	}
 
 	/* save the device name to sbi */
@@ -452,10 +453,6 @@ static int erofs_read_super(struct super_block *sb,
 	 */
 err_devname:
 	dput(sb->s_root);
-err_makeroot:
-err_isdir:
-	if (sb->s_root == NULL)
-		iput(inode);
 err_iget:
 #ifdef EROFS_FS_HAS_MANAGED_CACHE
 	iput(sbi->managed_cache);
-- 
2.20.1

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

* [PATCH] staging: erofs: fix potential double iput in erofs_read_super()
  2019-01-23  6:12 [PATCH] staging: erofs: fix potential double iput in erofs_read_super() Chengguang Xu
@ 2019-01-23 13:46 ` Gao Xiang
  2019-01-24  8:46 ` Chao Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2019-01-23 13:46 UTC (permalink / raw)




On 2019/1/23 14:12, Chengguang Xu wrote:
> Some error cases like failing from d_make_root() will
> cause double iput because d_make_root() also does iput
> in its error path.
> 
> Signed-off-by: Chengguang Xu <cgxu519 at gmx.com>

Looks good to me :) I did some basic test as well,
and it seems fine.

Reviewed-by: Gao Xiang <gaoxiang25 at huawei.com>

Thanks,
Gao Xiang

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

* [PATCH] staging: erofs: fix potential double iput in erofs_read_super()
  2019-01-23  6:12 [PATCH] staging: erofs: fix potential double iput in erofs_read_super() Chengguang Xu
  2019-01-23 13:46 ` Gao Xiang
@ 2019-01-24  8:46 ` Chao Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2019-01-24  8:46 UTC (permalink / raw)


On 2019/1/23 14:12, Chengguang Xu wrote:
> Some error cases like failing from d_make_root() will
> cause double iput because d_make_root() also does iput
> in its error path.
> 
> Signed-off-by: Chengguang Xu <cgxu519 at gmx.com>

Reviewed-by: Chao Yu <yuchao0 at huawei.com>

Thanks,

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

end of thread, other threads:[~2019-01-24  8:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23  6:12 [PATCH] staging: erofs: fix potential double iput in erofs_read_super() Chengguang Xu
2019-01-23 13:46 ` Gao Xiang
2019-01-24  8:46 ` Chao Yu

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.