public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: return specific error when pointer is NULL
@ 2021-12-23  2:24 Qing Wang
  2021-12-23  8:57 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Qing Wang @ 2021-12-23  2:24 UTC (permalink / raw)
  To: Jens Axboe, linux-block, linux-kernel; +Cc: Wang Qing

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


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

end of thread, other threads:[~2021-12-23  8:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-23  2:24 [PATCH] block: return specific error when pointer is NULL Qing Wang
2021-12-23  8:57 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox