From: Dan Carpenter <dan.carpenter@oracle.com>
To: Danil Kipnis <danil.kipnis@cloud.ionos.com>,
Jack Wang <jinpu.wang@cloud.ionos.com>
Cc: Jens Axboe <axboe@kernel.dk>, Jason Gunthorpe <jgg@ziepe.ca>,
Bart Van Assche <bvanassche@acm.org>,
linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] block/rnbd: Fix an IS_ERR() vs NULL check in find_or_create_sess()
Date: Tue, 19 May 2020 15:03:47 +0300 [thread overview]
Message-ID: <20200519120347.GD42765@mwanda> (raw)
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
next reply other threads:[~2020-05-19 12:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 12:03 Dan Carpenter [this message]
2020-05-19 12:52 ` [PATCH] block/rnbd: Fix an IS_ERR() vs NULL check in find_or_create_sess() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200519120347.GD42765@mwanda \
--to=dan.carpenter@oracle.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=danil.kipnis@cloud.ionos.com \
--cc=jgg@ziepe.ca \
--cc=jinpu.wang@cloud.ionos.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox