linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block/rnbd: Fix an IS_ERR() vs NULL check in find_or_create_sess()
@ 2020-05-19 12:03 Dan Carpenter
  2020-05-19 12:52 ` Jinpu Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2020-05-19 12:03 UTC (permalink / raw)
  To: Danil Kipnis, Jack Wang
  Cc: Jens Axboe, Jason Gunthorpe, Bart Van Assche, linux-block,
	kernel-janitors

The alloc_sess() function returns error pointers, it never returns NULL.

Fixes: f7a7a5c228d4 ("block/rnbd: client: main functionality")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/block/rnbd/rnbd-clt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index 55bff3b1be71..a033247281da 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);
-- 
2.26.2


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

end of thread, other threads:[~2020-05-22 16:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-19 12:03 [PATCH] block/rnbd: Fix an IS_ERR() vs NULL check in find_or_create_sess() Dan Carpenter
2020-05-19 12:52 ` Jinpu Wang
2020-05-22  5:13   ` Jinpu Wang
2020-05-22 14:48     ` Jason Gunthorpe
2020-05-22 15:44       ` Dan Carpenter
2020-05-22 16:41         ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).