xa_load() needs a NULL check before locking check
Subsystems (2)
PATCH 1/1 xa_load() needs a NULL check before locking check
Signed-off-by void0red <[email protected]>
--- include/linux/pagemap.h | 4 ++++ 1 file changed, 4 insertions(+)
include/linux/pagemap.h +4 -0
@@ -1250,6 +1250,10 @@ static inline struct folio *__readahead_folio(struct readahead_control *ractl) } folio =xa_load (&ractl->mapping->i_pages, ractl->_index); +if (!folio) { +VM_BUG_ON (!folio); +return NULL ; + }VM_BUG_ON_FOLIO (!folio_test_locked (folio), folio); ractl->_batch_count =folio_nr_pages (folio);
Signature · 1 line
2.34.1
Matthew Wilcox
maintainerinclude/linux/pagemap.h static inline struct folio *__readahead_folio(struct readahead_control *ractl) · line 1257
Quoted 6 lines · On Wed, Feb 15, 2023 at 09:14:17PM +0800, void0red wrote:
include/linux/pagemap.h +4
-0folio =xa_load (&ractl->mapping->i_pages, ractl->_index); +if (!folio) { +VM_BUG_ON (!folio); +return NULL ; + }VM_BUG_ON_FOLIO (!folio_test_locked (folio), folio);
Why does this need to happen? The caller has inserted all these folios into the xarray. They're locked, so they can't be removed. If they're not there, something has gone horribly wrong and crashing is a good response.
Quoted 5 lines
ractl->_batch_count=folio_nr_pages(folio);Signature · 1 line
2.34.1