* [bug report] gfs2: Convert gfs2_jhead_process_page() to use a folio
@ 2023-10-12 9:43 Dan Carpenter
2023-10-12 15:27 ` Matthew Wilcox
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2023-10-12 9:43 UTC (permalink / raw)
To: willy; +Cc: gfs2
Hello Matthew Wilcox (Oracle),
The patch 240159077d00: "gfs2: Convert gfs2_jhead_process_page() to
use a folio" from May 13, 2022 (linux-next), leads to the following
Smatch static checker warning:
fs/gfs2/lops.c:485 gfs2_jhead_process_page()
error: 'folio' dereferencing possible ERR_PTR()
fs/gfs2/lops.c
469 static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index,
470 struct gfs2_log_header_host *head,
471 bool *done)
472 {
473 struct folio *folio;
474
475 folio = filemap_get_folio(jd->jd_inode->i_mapping, index);
Does filemap_get_folio() need to be checked for errors?
476
477 folio_wait_locked(folio);
478 if (folio_test_error(folio))
479 *done = true;
480
481 if (!*done)
482 *done = gfs2_jhead_pg_srch(jd, head, &folio->page);
483
484 /* filemap_get_folio() and the earlier grab_cache_page() */
--> 485 folio_put_refs(folio, 2);
486 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] gfs2: Convert gfs2_jhead_process_page() to use a folio
2023-10-12 9:43 [bug report] gfs2: Convert gfs2_jhead_process_page() to use a folio Dan Carpenter
@ 2023-10-12 15:27 ` Matthew Wilcox
2023-10-13 6:28 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2023-10-12 15:27 UTC (permalink / raw)
To: Dan Carpenter; +Cc: gfs2
On Thu, Oct 12, 2023 at 12:43:34PM +0300, Dan Carpenter wrote:
> Hello Matthew Wilcox (Oracle),
>
> The patch 240159077d00: "gfs2: Convert gfs2_jhead_process_page() to
> use a folio" from May 13, 2022 (linux-next), leads to the following
> Smatch static checker warning:
>
> fs/gfs2/lops.c:485 gfs2_jhead_process_page()
> error: 'folio' dereferencing possible ERR_PTR()
>
> fs/gfs2/lops.c
> 469 static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index,
> 470 struct gfs2_log_header_host *head,
> 471 bool *done)
> 472 {
> 473 struct folio *folio;
> 474
> 475 folio = filemap_get_folio(jd->jd_inode->i_mapping, index);
>
> Does filemap_get_folio() need to be checked for errors?
In this specific case, we know that the folio is there and will always
be returned. See the comment on line 484. Can I annotate this call so
that the tool knows this is a special case and doesn't warn about it?
> 476
> 477 folio_wait_locked(folio);
> 478 if (folio_test_error(folio))
> 479 *done = true;
> 480
> 481 if (!*done)
> 482 *done = gfs2_jhead_pg_srch(jd, head, &folio->page);
> 483
> 484 /* filemap_get_folio() and the earlier grab_cache_page() */
> --> 485 folio_put_refs(folio, 2);
> 486 }
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [bug report] gfs2: Convert gfs2_jhead_process_page() to use a folio
2023-10-12 15:27 ` Matthew Wilcox
@ 2023-10-13 6:28 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-10-13 6:28 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: gfs2
On Thu, Oct 12, 2023 at 04:27:55PM +0100, Matthew Wilcox wrote:
> On Thu, Oct 12, 2023 at 12:43:34PM +0300, Dan Carpenter wrote:
> > Hello Matthew Wilcox (Oracle),
> >
> > The patch 240159077d00: "gfs2: Convert gfs2_jhead_process_page() to
> > use a folio" from May 13, 2022 (linux-next), leads to the following
> > Smatch static checker warning:
> >
> > fs/gfs2/lops.c:485 gfs2_jhead_process_page()
> > error: 'folio' dereferencing possible ERR_PTR()
> >
> > fs/gfs2/lops.c
> > 469 static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index,
> > 470 struct gfs2_log_header_host *head,
> > 471 bool *done)
> > 472 {
> > 473 struct folio *folio;
> > 474
> > 475 folio = filemap_get_folio(jd->jd_inode->i_mapping, index);
> >
> > Does filemap_get_folio() need to be checked for errors?
>
> In this specific case, we know that the folio is there and will always
> be returned. See the comment on line 484. Can I annotate this call so
> that the tool knows this is a special case and doesn't warn about it?
>
Thanks for looking at this. There is no annotation. In the kernel we
are very good at fixing static checker warnings so everything old is a
false positive.
This one is from May but I recently changed how dereferences were
handled so it's the first time I had seen the warning.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-13 6:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-12 9:43 [bug report] gfs2: Convert gfs2_jhead_process_page() to use a folio Dan Carpenter
2023-10-12 15:27 ` Matthew Wilcox
2023-10-13 6:28 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox