* [PATCH] ceph: fix NULL vs IS_ERR() bug in ceph_zero_partial_page()
@ 2025-06-25 15:22 Dan Carpenter
2025-06-27 19:52 ` Viacheslav Dubeyko
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-06-25 15:22 UTC (permalink / raw)
To: Xiubo Li
Cc: Ilya Dryomov, Andrew Morton, Matthew Wilcox (Oracle), ceph-devel,
linux-kernel, kernel-janitors
The filemap_lock_folio() never returns NULL. It returns error pointers.
Update the checking to match.
Fixes: 483239f03149 ("ceph: convert ceph_zero_partial_page() to use a folio")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
fs/ceph/file.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index d5c674d2ba8a..f6e63265c516 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -2536,12 +2536,13 @@ static inline void ceph_zero_partial_page(struct inode *inode,
struct folio *folio;
folio = filemap_lock_folio(inode->i_mapping, offset >> PAGE_SHIFT);
- if (folio) {
- folio_wait_writeback(folio);
- folio_zero_range(folio, offset_in_folio(folio, offset), size);
- folio_unlock(folio);
- folio_put(folio);
- }
+ if (IS_ERR(folio))
+ return;
+
+ folio_wait_writeback(folio);
+ folio_zero_range(folio, offset_in_folio(folio, offset), size);
+ folio_unlock(folio);
+ folio_put(folio);
}
static void ceph_zero_pagecache_range(struct inode *inode, loff_t offset,
--
2.47.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ceph: fix NULL vs IS_ERR() bug in ceph_zero_partial_page()
2025-06-25 15:22 [PATCH] ceph: fix NULL vs IS_ERR() bug in ceph_zero_partial_page() Dan Carpenter
@ 2025-06-27 19:52 ` Viacheslav Dubeyko
0 siblings, 0 replies; 2+ messages in thread
From: Viacheslav Dubeyko @ 2025-06-27 19:52 UTC (permalink / raw)
To: Xiubo Li, dan.carpenter@linaro.org
Cc: kernel-janitors@vger.kernel.org, idryomov@gmail.com,
willy@infradead.org, linux-kernel@vger.kernel.org,
ceph-devel@vger.kernel.org, akpm@linux-foundation.org
On Wed, 2025-06-25 at 10:22 -0500, Dan Carpenter wrote:
> The filemap_lock_folio() never returns NULL. It returns error pointers.
> Update the checking to match.
>
> Fixes: 483239f03149 ("ceph: convert ceph_zero_partial_page() to use a folio")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> fs/ceph/file.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index d5c674d2ba8a..f6e63265c516 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -2536,12 +2536,13 @@ static inline void ceph_zero_partial_page(struct inode *inode,
> struct folio *folio;
>
> folio = filemap_lock_folio(inode->i_mapping, offset >> PAGE_SHIFT);
> - if (folio) {
> - folio_wait_writeback(folio);
> - folio_zero_range(folio, offset_in_folio(folio, offset), size);
> - folio_unlock(folio);
> - folio_put(folio);
> - }
> + if (IS_ERR(folio))
> + return;
> +
> + folio_wait_writeback(folio);
> + folio_zero_range(folio, offset_in_folio(folio, offset), size);
> + folio_unlock(folio);
> + folio_put(folio);
> }
>
> static void ceph_zero_pagecache_range(struct inode *inode, loff_t offset,
Looks good!
Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Thanks,
Slava.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-27 19:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 15:22 [PATCH] ceph: fix NULL vs IS_ERR() bug in ceph_zero_partial_page() Dan Carpenter
2025-06-27 19:52 ` Viacheslav Dubeyko
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).