diff mbox

[V9fs-developer] xen/9pfs: fix return value check in xen_9pfs_front_probe()

Message ID 20170516142247.12301-1-weiyj.lk@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Wei Yongjun May 16, 2017, 2:22 p.m. UTC
From: Wei Yongjun <weiyongjun1@huawei.com>

In case of error, the function xenbus_read() returns ERR_PTR() and never
returns NULL. The NULL test in the return value check should be replaced
with IS_ERR().

Fixes: 71ebd71921e4 ("xen/9pfs: connect to the backend")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 net/9p/trans_xen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

Comments

Stefano Stabellini May 16, 2017, 6:35 p.m. UTC | #1
On Tue, 16 May 2017, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> In case of error, the function xenbus_read() returns ERR_PTR() and never
> returns NULL. The NULL test in the return value check should be replaced
> with IS_ERR().
> 
> Fixes: 71ebd71921e4 ("xen/9pfs: connect to the backend")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Thank you!

> ---
>  net/9p/trans_xen.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
> index 71e8564..83fe487 100644
> --- a/net/9p/trans_xen.c
> +++ b/net/9p/trans_xen.c
> @@ -454,8 +454,8 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
>  			goto error_xenbus;
>  	}
>  	priv->tag = xenbus_read(xbt, dev->nodename, "tag", NULL);
> -	if (!priv->tag) {
> -		ret = -EINVAL;
> +	if (IS_ERR(priv->tag)) {
> +		ret = PTR_ERR(priv->tag);
>  		goto error_xenbus;
>  	}
>  	ret = xenbus_transaction_end(xbt, 0);
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
diff mbox

Patch

diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index 71e8564..83fe487 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -454,8 +454,8 @@  static int xen_9pfs_front_probe(struct xenbus_device *dev,
 			goto error_xenbus;
 	}
 	priv->tag = xenbus_read(xbt, dev->nodename, "tag", NULL);
-	if (!priv->tag) {
-		ret = -EINVAL;
+	if (IS_ERR(priv->tag)) {
+		ret = PTR_ERR(priv->tag);
 		goto error_xenbus;
 	}
 	ret = xenbus_transaction_end(xbt, 0);