CC: [email protected] TO: David Howells <[email protected]> tree: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git fscache-next head: 12a86789cc2c154ad43d6d2eeadc650abb82d4e8 commit: 5792dce657e8513906c6c0fad19d6184cfa1b7a6 [4/5] netfs: Fix various bits of error handling :::::: branch date: 9 hours ago :::::: commit date: 10 hours ago config: x86_64-randconfig-m001-20210202 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> smatch warnings: fs/netfs/read_helper.c:402 netfs_rreq_unlock() warn: variable dereferenced before check 'subreq' (see line 391) vim +/subreq +402 fs/netfs/read_helper.c 99fed40841c462 David Howells 2020-02-06 358 467ef3015ee489 David Howells 2020-05-13 359 /* 467ef3015ee489 David Howells 2020-05-13 360 * Unlock the pages in a read operation. We need to set PG_fscache on any 467ef3015ee489 David Howells 2020-05-13 361 * pages we're going to write back before we unlock them. 467ef3015ee489 David Howells 2020-05-13 362 */ 467ef3015ee489 David Howells 2020-05-13 363 static void netfs_rreq_unlock(struct netfs_read_request *rreq) 467ef3015ee489 David Howells 2020-05-13 364 { 467ef3015ee489 David Howells 2020-05-13 365 struct netfs_read_subrequest *subreq; 467ef3015ee489 David Howells 2020-05-13 366 struct page *page; 467ef3015ee489 David Howells 2020-05-13 367 unsigned int iopos, account = 0; 467ef3015ee489 David Howells 2020-05-13 368 pgoff_t start_page = rreq->start / PAGE_SIZE; 467ef3015ee489 David Howells 2020-05-13 369 pgoff_t last_page = ((rreq->start + rreq->len) / PAGE_SIZE) - 1; 467ef3015ee489 David Howells 2020-05-13 370 bool subreq_failed = false; 467ef3015ee489 David Howells 2020-05-13 371 int i; 467ef3015ee489 David Howells 2020-05-13 372 467ef3015ee489 David Howells 2020-05-13 373 XA_STATE(xas, &rreq->mapping->i_pages, start_page); 467ef3015ee489 David Howells 2020-05-13 374 467ef3015ee489 David Howells 2020-05-13 375 if (test_bit(NETFS_RREQ_FAILED, &rreq->flags)) { 467ef3015ee489 David Howells 2020-05-13 376 __clear_bit(NETFS_RREQ_WRITE_TO_CACHE, &rreq->flags); 467ef3015ee489 David Howells 2020-05-13 377 list_for_each_entry(subreq, &rreq->subrequests, rreq_link) { 467ef3015ee489 David Howells 2020-05-13 378 __clear_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags); 467ef3015ee489 David Howells 2020-05-13 379 } 467ef3015ee489 David Howells 2020-05-13 380 } 467ef3015ee489 David Howells 2020-05-13 381 467ef3015ee489 David Howells 2020-05-13 382 /* Walk through the pagecache and the I/O request lists simultaneously. 467ef3015ee489 David Howells 2020-05-13 383 * We may have a mixture of cached and uncached sections and we only 467ef3015ee489 David Howells 2020-05-13 384 * really want to write out the uncached sections. This is slightly 467ef3015ee489 David Howells 2020-05-13 385 * complicated by the possibility that we might have huge pages with a 467ef3015ee489 David Howells 2020-05-13 386 * mixture inside. 467ef3015ee489 David Howells 2020-05-13 387 */ 467ef3015ee489 David Howells 2020-05-13 388 subreq = list_first_entry(&rreq->subrequests, 467ef3015ee489 David Howells 2020-05-13 389 struct netfs_read_subrequest, rreq_link); 467ef3015ee489 David Howells 2020-05-13 390 iopos = 0; 467ef3015ee489 David Howells 2020-05-13 @391 subreq_failed = (subreq->error < 0); 467ef3015ee489 David Howells 2020-05-13 392 f36fd472366d6d David Howells 2020-09-18 393 trace_netfs_rreq(rreq, netfs_rreq_trace_unlock); f36fd472366d6d David Howells 2020-09-18 394 467ef3015ee489 David Howells 2020-05-13 395 rcu_read_lock(); 467ef3015ee489 David Howells 2020-05-13 396 xas_for_each(&xas, page, last_page) { 467ef3015ee489 David Howells 2020-05-13 397 unsigned int pgpos = (page->index - start_page) * PAGE_SIZE; 467ef3015ee489 David Howells 2020-05-13 398 unsigned int pgend = pgpos + thp_size(page); 467ef3015ee489 David Howells 2020-05-13 399 bool pg_failed = false; 467ef3015ee489 David Howells 2020-05-13 400 467ef3015ee489 David Howells 2020-05-13 401 for (;;) { 5792dce657e851 David Howells 2021-02-02 @402 if (!subreq) { 5792dce657e851 David Howells 2021-02-02 403 pg_failed = true; 5792dce657e851 David Howells 2021-02-02 404 break; 5792dce657e851 David Howells 2021-02-02 405 } 467ef3015ee489 David Howells 2020-05-13 406 if (test_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags)) 467ef3015ee489 David Howells 2020-05-13 407 SetPageFsCache(page); 467ef3015ee489 David Howells 2020-05-13 408 pg_failed |= subreq_failed; 467ef3015ee489 David Howells 2020-05-13 409 if (pgend < iopos + subreq->len) 467ef3015ee489 David Howells 2020-05-13 410 break; 467ef3015ee489 David Howells 2020-05-13 411 467ef3015ee489 David Howells 2020-05-13 412 account += subreq->transferred; 467ef3015ee489 David Howells 2020-05-13 413 iopos += subreq->len; 467ef3015ee489 David Howells 2020-05-13 414 if (!list_is_last(&subreq->rreq_link, &rreq->subrequests)) { 467ef3015ee489 David Howells 2020-05-13 415 subreq = list_next_entry(subreq, rreq_link); 467ef3015ee489 David Howells 2020-05-13 416 subreq_failed = (subreq->error < 0); 467ef3015ee489 David Howells 2020-05-13 417 } else { 467ef3015ee489 David Howells 2020-05-13 418 subreq = NULL; 467ef3015ee489 David Howells 2020-05-13 419 subreq_failed = false; 467ef3015ee489 David Howells 2020-05-13 420 } 467ef3015ee489 David Howells 2020-05-13 421 if (pgend == iopos) 467ef3015ee489 David Howells 2020-05-13 422 break; 467ef3015ee489 David Howells 2020-05-13 423 } 467ef3015ee489 David Howells 2020-05-13 424 5792dce657e851 David Howells 2021-02-02 425 if (!pg_failed) { 467ef3015ee489 David Howells 2020-05-13 426 for (i = 0; i < thp_nr_pages(page); i++) 467ef3015ee489 David Howells 2020-05-13 427 flush_dcache_page(page); 467ef3015ee489 David Howells 2020-05-13 428 SetPageUptodate(page); 467ef3015ee489 David Howells 2020-05-13 429 } 467ef3015ee489 David Howells 2020-05-13 430 467ef3015ee489 David Howells 2020-05-13 431 if (!test_bit(NETFS_RREQ_DONT_UNLOCK_PAGES, &rreq->flags)) { 467ef3015ee489 David Howells 2020-05-13 432 if (page->index == rreq->no_unlock_page && 467ef3015ee489 David Howells 2020-05-13 433 test_bit(NETFS_RREQ_NO_UNLOCK_PAGE, &rreq->flags)) 467ef3015ee489 David Howells 2020-05-13 434 _debug("no unlock"); 467ef3015ee489 David Howells 2020-05-13 435 else 467ef3015ee489 David Howells 2020-05-13 436 unlock_page(page); 467ef3015ee489 David Howells 2020-05-13 437 } 467ef3015ee489 David Howells 2020-05-13 438 } 467ef3015ee489 David Howells 2020-05-13 439 rcu_read_unlock(); 467ef3015ee489 David Howells 2020-05-13 440 467ef3015ee489 David Howells 2020-05-13 441 task_io_account_read(account); 467ef3015ee489 David Howells 2020-05-13 442 if (rreq->netfs_ops->done) 467ef3015ee489 David Howells 2020-05-13 443 rreq->netfs_ops->done(rreq); 467ef3015ee489 David Howells 2020-05-13 444 } 467ef3015ee489 David Howells 2020-05-13 445 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected]
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
