summaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2020-05-19 15:03:47 +0300
committerJason Gunthorpe <jgg@mellanox.com>2020-05-22 11:51:36 -0300
commit47393fb57ba7b914c869f70010326c8b8940c3a0 (patch)
tree7889b3d76c2b9ba3a4f41d0a85d565e4041b6e79 /drivers/block
parent6d1e7ba241e990b5c6ba7fdaa03d466f852f3c9e (diff)
block/rnbd: Fix an IS_ERR() vs NULL check in find_or_create_sess()
The alloc_sess() function returns error pointers, it never returns NULL. Fixes: f7a7a5c228d4 ("block/rnbd: client: main functionality") Link: https://lore.kernel.org/r/20200519120347.GD42765@mwanda Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Jack Wang <jinpu.wang@cloud.ionos.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rnbd/rnbd-clt.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index 450a571e6a1e..cc6a4e2587ae 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -923,13 +923,12 @@ rnbd_clt_session *find_or_create_sess(const char *sessname, bool *first)
sess = __find_and_get_sess(sessname);
if (!sess) {
sess = alloc_sess(sessname);
- if (sess) {
- list_add(&sess->list, &sess_list);
- *first = true;
- } else {
+ if (IS_ERR(sess)) {
mutex_unlock(&sess_lock);
- return ERR_PTR(-ENOMEM);
+ return sess;
}
+ list_add(&sess->list, &sess_list);
+ *first = true;
} else
*first = false;
mutex_unlock(&sess_lock);