From: Qing Wang <wangqing@vivo.com>
To: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Wang Qing <wangqing@vivo.com>
Subject: [PATCH] block: return specific error when pointer is NULL
Date: Wed, 22 Dec 2021 18:24:03 -0800 [thread overview]
Message-ID: <1640226246-32691-1-git-send-email-wangqing@vivo.com> (raw)
From: Wang Qing <wangqing@vivo.com>
loop_attr_backing_file_show() better return specific error than 0
when pointer is NULL
Signed-off-by: Wang Qing <wangqing@vivo.com>
---
drivers/block/loop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index e52a8a5..860a5b6
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -667,7 +667,7 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf)
spin_unlock_irq(&lo->lo_lock);
if (IS_ERR_OR_NULL(p))
- ret = PTR_ERR(p);
+ ret = p ? PTR_ERR(p) : -ENOENT;
else {
ret = strlen(p);
memmove(buf, p, ret);
--
2.7.4
next reply other threads:[~2021-12-23 2:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-23 2:24 Qing Wang [this message]
2021-12-23 8:57 ` [PATCH] block: return specific error when pointer is NULL Christoph Hellwig
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=1640226246-32691-1-git-send-email-wangqing@vivo.com \
--to=wangqing@vivo.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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