2019-01-16 20:41:42

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next] binderfs: fix error return code in binderfs_fill_super()

Fix to return a negative error code -ENOMEM from the new_inode() and
d_make_root() error handling cases instead of 0, as done elsewhere in
this function.

Fixes: 3ad20fe393b3 ("binder: implement binderfs")
Signed-off-by: Wei Yongjun <[email protected]>
---
drivers/android/binderfs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index 9518e2e..2bf4b2b 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -519,8 +519,10 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_fs_info = info;

inode = new_inode(sb);
- if (!inode)
+ if (!inode) {
+ ret = -ENOMEM;
goto err_without_dentry;
+ }

inode->i_ino = FIRST_INODE;
inode->i_fop = &simple_dir_operations;
@@ -530,8 +532,10 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
set_nlink(inode, 2);

sb->s_root = d_make_root(inode);
- if (!sb->s_root)
+ if (!sb->s_root) {
+ ret = -ENOMEM;
goto err_without_dentry;
+ }

ret = binderfs_binder_ctl_create(sb);
if (ret)





2019-01-16 16:35:32

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH -next] binderfs: fix error return code in binderfs_fill_super()

On Wed, Jan 16, 2019 at 07:25:46AM +0100, Christian Brauner wrote:
> On Wed, Jan 16, 2019 at 03:01:04AM +0000, Wei Yongjun wrote:
> > Fix to return a negative error code -ENOMEM from the new_inode() and
> > d_make_root() error handling cases instead of 0, as done elsewhere in
> > this function.
> >
> > Fixes: 3ad20fe393b3 ("binder: implement binderfs")

This Fixes tag is technically wrong since this codepath was introduced
by a commit that is still sitting in Greg's char-misc-linus branch. Not
sure how to handle that though. Might just leave it.

> > Signed-off-by: Wei Yongjun <[email protected]>
> > ---
> > drivers/android/binderfs.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
> > index 9518e2e..2bf4b2b 100644
> > --- a/drivers/android/binderfs.c
> > +++ b/drivers/android/binderfs.c
> > @@ -519,8 +519,10 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
> > sb->s_fs_info = info;
> >
> > inode = new_inode(sb);
> > - if (!inode)
> > + if (!inode) {
> > + ret = -ENOMEM;
>
> Hey, thanks for the patch. Just a nit:
> can you please just do?
>
> ret = -ENOMEM;
> inode = new_inode(sb);
>
> This is more consistent with how we do it everywhere else and let's us
> avoid shoving ret = -ENOMEM into two places.
>
> Thanks!
> Christian
>
> > goto err_without_dentry;
> > + }
> >
> > inode->i_ino = FIRST_INODE;
> > inode->i_fop = &simple_dir_operations;
> > @@ -530,8 +532,10 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
> > set_nlink(inode, 2);
> >
> > sb->s_root = d_make_root(inode);
> > - if (!sb->s_root)
> > + if (!sb->s_root) {
> > + ret = -ENOMEM;
> > goto err_without_dentry;
> > + }
> >
> > ret = binderfs_binder_ctl_create(sb);
> > if (ret)
> >
> >
> >

2019-01-16 18:11:12

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH -next] binderfs: fix error return code in binderfs_fill_super()

On Wed, Jan 16, 2019 at 03:01:04AM +0000, Wei Yongjun wrote:
> Fix to return a negative error code -ENOMEM from the new_inode() and
> d_make_root() error handling cases instead of 0, as done elsewhere in
> this function.
>
> Fixes: 3ad20fe393b3 ("binder: implement binderfs")
> Signed-off-by: Wei Yongjun <[email protected]>
> ---
> drivers/android/binderfs.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
> index 9518e2e..2bf4b2b 100644
> --- a/drivers/android/binderfs.c
> +++ b/drivers/android/binderfs.c
> @@ -519,8 +519,10 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
> sb->s_fs_info = info;
>
> inode = new_inode(sb);
> - if (!inode)
> + if (!inode) {
> + ret = -ENOMEM;

Hey, thanks for the patch. Just a nit:
can you please just do?

ret = -ENOMEM;
inode = new_inode(sb);

This is more consistent with how we do it everywhere else and let's us
avoid shoving ret = -ENOMEM into two places.

Thanks!
Christian

> goto err_without_dentry;
> + }
>
> inode->i_ino = FIRST_INODE;
> inode->i_fop = &simple_dir_operations;
> @@ -530,8 +532,10 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
> set_nlink(inode, 2);
>
> sb->s_root = d_make_root(inode);
> - if (!sb->s_root)
> + if (!sb->s_root) {
> + ret = -ENOMEM;
> goto err_without_dentry;
> + }
>
> ret = binderfs_binder_ctl_create(sb);
> if (ret)
>
>
>

2019-01-16 18:27:22

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH -next] binderfs: fix error return code in binderfs_fill_super()

On Wed, Jan 16, 2019 at 07:28:26AM +0100, Christian Brauner wrote:
> On Wed, Jan 16, 2019 at 07:25:46AM +0100, Christian Brauner wrote:
> > On Wed, Jan 16, 2019 at 03:01:04AM +0000, Wei Yongjun wrote:
> > > Fix to return a negative error code -ENOMEM from the new_inode() and
> > > d_make_root() error handling cases instead of 0, as done elsewhere in
> > > this function.
> > >
> > > Fixes: 3ad20fe393b3 ("binder: implement binderfs")
>
> This Fixes tag is technically wrong since this codepath was introduced
> by a commit that is still sitting in Greg's char-misc-linus branch. Not
> sure how to handle that though. Might just leave it.

Use the git commit id of the patch in that branch, it is not going to
change as I do not rebase that branch.

thanks,

greg k-h

2019-01-16 18:30:13

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH -next v2] binderfs: fix error return code in binderfs_fill_super()

On Wed, Jan 16, 2019 at 08:34:02AM +0000, Wei Yongjun wrote:
> Fix to return a negative error code -ENOMEM from the new_inode() and
> d_make_root() error handling cases instead of 0, as done elsewhere in
> this function.
>
> Fixes: 3ad20fe393b3 ("binder: implement binderfs")

This should be:

Fixes: 849d540ddfcd ("binderfs: implement "max" mount option")

If you have added that feel free to also add my Reviewed-by.

Thanks!
Christian

> Signed-off-by: Wei Yongjun <[email protected]>
> ---
> v1 -> v2: move 'ret = -ENOMEM' out of if
> ---
> drivers/android/binderfs.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
> index 9518e2e..e4ff4c3 100644
> --- a/drivers/android/binderfs.c
> +++ b/drivers/android/binderfs.c
> @@ -518,6 +518,7 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
>
> sb->s_fs_info = info;
>
> + ret = -ENOMEM;
> inode = new_inode(sb);
> if (!inode)
> goto err_without_dentry;
>
>
>

2019-01-16 21:20:32

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH -next v2] binderfs: fix error return code in binderfs_fill_super()

On Wed, Jan 16, 2019 at 09:41:08AM +0100, Christian Brauner wrote:
> On Wed, Jan 16, 2019 at 08:34:02AM +0000, Wei Yongjun wrote:
> > Fix to return a negative error code -ENOMEM from the new_inode() and
> > d_make_root() error handling cases instead of 0, as done elsewhere in
> > this function.
> >
> > Fixes: 3ad20fe393b3 ("binder: implement binderfs")
>
> This should be:
>
> Fixes: 849d540ddfcd ("binderfs: implement "max" mount option")
>
> If you have added that feel free to also add my Reviewed-by.

Also, this does need to go into char-misc-linus and not -next so you can
drop the -next prefix from the [PATCH ...] prefix. :) Greg will do the
right thing in any case but it's just clearer if you don't add it. :)

Thanks!
Christian

2019-01-16 21:20:39

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next v2] binderfs: fix error return code in binderfs_fill_super()

Fix to return a negative error code -ENOMEM from the new_inode() and
d_make_root() error handling cases instead of 0, as done elsewhere in
this function.

Fixes: 3ad20fe393b3 ("binder: implement binderfs")
Signed-off-by: Wei Yongjun <[email protected]>
---
v1 -> v2: move 'ret = -ENOMEM' out of if
---
drivers/android/binderfs.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index 9518e2e..e4ff4c3 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -518,6 +518,7 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)

sb->s_fs_info = info;

+ ret = -ENOMEM;
inode = new_inode(sb);
if (!inode)
goto err_without_dentry;




2019-01-16 21:21:24

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH -next] binderfs: fix error return code in binderfs_fill_super()

On Wed, Jan 16, 2019 at 07:25:47AM +0100, Christian Brauner wrote:
> On Wed, Jan 16, 2019 at 03:01:04AM +0000, Wei Yongjun wrote:
> > Fix to return a negative error code -ENOMEM from the new_inode() and
> > d_make_root() error handling cases instead of 0, as done elsewhere in
> > this function.
> >
> > Fixes: 3ad20fe393b3 ("binder: implement binderfs")
> > Signed-off-by: Wei Yongjun <[email protected]>
> > ---
> > drivers/android/binderfs.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
> > index 9518e2e..2bf4b2b 100644
> > --- a/drivers/android/binderfs.c
> > +++ b/drivers/android/binderfs.c
> > @@ -519,8 +519,10 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)
> > sb->s_fs_info = info;
> >
> > inode = new_inode(sb);
> > - if (!inode)
> > + if (!inode) {
> > + ret = -ENOMEM;
>
> Hey, thanks for the patch. Just a nit:
> can you please just do?
>
> ret = -ENOMEM;
> inode = new_inode(sb);
>
> This is more consistent with how we do it everywhere else and let's us
> avoid shoving ret = -ENOMEM into two places.
>

Btw, your style is why you have this bug. I don't have strong feelings
about this either way, I'm just pointing it out.

regards,
dan carpenter


2019-01-16 21:30:13

by Wei Yongjun

[permalink] [raw]
Subject: RE: [PATCH v3] binderfs: fix error return code in binderfs_fill_super()

Sorry, please ignore this patch, missing reviewed-by line, I will send a new version.

> -----Original Message-----
> From: weiyongjun (A)
> Sent: Wednesday, January 16, 2019 6:39 PM
> To: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]
> Cc: weiyongjun (A) <[email protected]>;
> [email protected]; [email protected]; kernel-
> [email protected]
> Subject: [PATCH v3] binderfs: fix error return code in binderfs_fill_super()
>
> Fix to return a negative error code -ENOMEM from the new_inode() and
> d_make_root() error handling cases instead of 0, as done elsewhere in
> this function.
>
> Fixes: 849d540ddfcd ("binderfs: implement "max" mount option")
> Signed-off-by: Wei Yongjun <[email protected]>
> ---
> v1 -> v2: move 'ret = -ENOMEM' out of if
> v2 -> v3: use correct fixes commit
> ---
> drivers/android/binderfs.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
> index 9518e2e..e4ff4c3 100644
> --- a/drivers/android/binderfs.c
> +++ b/drivers/android/binderfs.c
> @@ -518,6 +518,7 @@ static int binderfs_fill_super(struct super_block *sb,
> void *data, int silent)
>
> sb->s_fs_info = info;
>
> + ret = -ENOMEM;
> inode = new_inode(sb);
> if (!inode)
> goto err_without_dentry;
>
>


2019-01-16 21:30:47

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH v3] binderfs: fix error return code in binderfs_fill_super()

Fix to return a negative error code -ENOMEM from the new_inode() and
d_make_root() error handling cases instead of 0, as done elsewhere in
this function.

Fixes: 849d540ddfcd ("binderfs: implement "max" mount option")
Signed-off-by: Wei Yongjun <[email protected]>
---
v1 -> v2: move 'ret = -ENOMEM' out of if
v2 -> v3: use correct fixes commit
---
drivers/android/binderfs.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index 9518e2e..e4ff4c3 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -518,6 +518,7 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)

sb->s_fs_info = info;

+ ret = -ENOMEM;
inode = new_inode(sb);
if (!inode)
goto err_without_dentry;




2019-01-17 04:25:36

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH v4] binderfs: fix error return code in binderfs_fill_super()

Fix to return a negative error code -ENOMEM from the new_inode() and
d_make_root() error handling cases instead of 0, as done elsewhere in
this function.

Fixes: 849d540ddfcd ("binderfs: implement "max" mount option")
Signed-off-by: Wei Yongjun <[email protected]>
Reviewed-by: Christian Brauner <[email protected]>
---
v1 -> v2: move 'ret = -ENOMEM' out of if
v2 -> v3: use correct fixes commit
v3 -> v4: add reviewed-by
---
drivers/android/binderfs.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index 9518e2e..e4ff4c3 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -518,6 +518,7 @@ static int binderfs_fill_super(struct super_block *sb, void *data, int silent)

sb->s_fs_info = info;

+ ret = -ENOMEM;
inode = new_inode(sb);
if (!inode)
goto err_without_dentry;