2024-01-22 13:17:53

by David Howells

[permalink] [raw]
Subject: [PATCH 05/10] netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write()

From: Dan Carpenter <[email protected]>

The netfs_grab_folio_for_write() function doesn't return NULL, it returns
error pointers. Update the check accordingly.

Fixes: c38f4e96e605 ("netfs: Provide func to copy data to pagecache for buffered write")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: David Howells <[email protected]>
Link: https://lore.kernel.org/r/[email protected]/
---
fs/netfs/buffered_write.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c
index e7f9ba6fb16b..a3059b3168fd 100644
--- a/fs/netfs/buffered_write.c
+++ b/fs/netfs/buffered_write.c
@@ -221,10 +221,11 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
if (unlikely(fault_in_iov_iter_readable(iter, part) == part))
break;

- ret = -ENOMEM;
folio = netfs_grab_folio_for_write(mapping, pos, part);
- if (!folio)
+ if (IS_ERR(folio)) {
+ ret = PTR_ERR(folio);
break;
+ }

flen = folio_size(folio);
offset = pos & (flen - 1);