[dhowells-fs:fscache-rewrite-indexing-2 50/64] fs/cachefiles/io.c:483 __cachefiles_prepare_write() error: uninitialized symbol 'ret'.
From: Dan Carpenter
Date: Wed Nov 10 2021 - 02:38:51 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git fscache-rewrite-indexing-2
head: 90bb44e5d6dcd202b7443fbe2dd1f71cd408b942
commit: 0cdb319c9ee8e62be3f3c395eabfd746515a8c9b [50/64] cachefiles: Implement the I/O routines
config: powerpc-randconfig-m031-20211101 (attached as .config)
compiler: powerpc-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
smatch warnings:
fs/cachefiles/io.c:483 __cachefiles_prepare_write() error: uninitialized symbol 'ret'.
vim +/ret +483 fs/cachefiles/io.c
0cdb319c9ee8e6 David Howells 2021-10-21 424 static int __cachefiles_prepare_write(struct netfs_cache_resources *cres,
0cdb319c9ee8e6 David Howells 2021-10-21 425 loff_t *_start, size_t *_len, loff_t i_size,
0cdb319c9ee8e6 David Howells 2021-10-21 426 bool no_space_allocated_yet)
0cdb319c9ee8e6 David Howells 2021-10-21 427 {
0cdb319c9ee8e6 David Howells 2021-10-21 428 struct cachefiles_object *object = cachefiles_cres_object(cres);
0cdb319c9ee8e6 David Howells 2021-10-21 429 struct cachefiles_cache *cache = object->volume->cache;
0cdb319c9ee8e6 David Howells 2021-10-21 430 struct file *file = cachefiles_cres_file(cres);
0cdb319c9ee8e6 David Howells 2021-10-21 431 loff_t start = *_start, pos;
0cdb319c9ee8e6 David Howells 2021-10-21 432 size_t len = *_len, down;
0cdb319c9ee8e6 David Howells 2021-10-21 433 int ret;
^^^^^^^^
0cdb319c9ee8e6 David Howells 2021-10-21 434
0cdb319c9ee8e6 David Howells 2021-10-21 435 /* Round to DIO size */
0cdb319c9ee8e6 David Howells 2021-10-21 436 down = start - round_down(start, PAGE_SIZE);
0cdb319c9ee8e6 David Howells 2021-10-21 437 *_start = start - down;
0cdb319c9ee8e6 David Howells 2021-10-21 438 *_len = round_up(down + len, PAGE_SIZE);
0cdb319c9ee8e6 David Howells 2021-10-21 439
0cdb319c9ee8e6 David Howells 2021-10-21 440 /* We need to work out whether there's sufficient disk space to perform
0cdb319c9ee8e6 David Howells 2021-10-21 441 * the write - but we can skip that check if we have space already
0cdb319c9ee8e6 David Howells 2021-10-21 442 * allocated.
0cdb319c9ee8e6 David Howells 2021-10-21 443 */
0cdb319c9ee8e6 David Howells 2021-10-21 444 if (no_space_allocated_yet)
0cdb319c9ee8e6 David Howells 2021-10-21 445 goto check_space;
0cdb319c9ee8e6 David Howells 2021-10-21 446
0cdb319c9ee8e6 David Howells 2021-10-21 447 pos = cachefiles_inject_read_error();
0cdb319c9ee8e6 David Howells 2021-10-21 448 if (pos == 0)
0cdb319c9ee8e6 David Howells 2021-10-21 449 pos = vfs_llseek(file, *_start, SEEK_DATA);
0cdb319c9ee8e6 David Howells 2021-10-21 450 if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
0cdb319c9ee8e6 David Howells 2021-10-21 451 if (pos == -ENXIO)
0cdb319c9ee8e6 David Howells 2021-10-21 452 goto check_space; /* Unallocated tail */
0cdb319c9ee8e6 David Howells 2021-10-21 453 trace_cachefiles_io_error(object, file_inode(file), pos,
0cdb319c9ee8e6 David Howells 2021-10-21 454 cachefiles_trace_seek_error);
0cdb319c9ee8e6 David Howells 2021-10-21 455 return pos;
0cdb319c9ee8e6 David Howells 2021-10-21 456 }
0cdb319c9ee8e6 David Howells 2021-10-21 457 if ((u64)pos >= (u64)*_start + *_len)
0cdb319c9ee8e6 David Howells 2021-10-21 458 goto check_space; /* Unallocated region */
0cdb319c9ee8e6 David Howells 2021-10-21 459
0cdb319c9ee8e6 David Howells 2021-10-21 460 /* We have a block that's at least partially filled - if we're low on
0cdb319c9ee8e6 David Howells 2021-10-21 461 * space, we need to see if it's fully allocated. If it's not, we may
0cdb319c9ee8e6 David Howells 2021-10-21 462 * want to cull it.
0cdb319c9ee8e6 David Howells 2021-10-21 463 */
0cdb319c9ee8e6 David Howells 2021-10-21 464 if (cachefiles_has_space(cache, 0, *_len / PAGE_SIZE) == 0)
0cdb319c9ee8e6 David Howells 2021-10-21 465 return 0; /* Enough space to simply overwrite the whole block */
0cdb319c9ee8e6 David Howells 2021-10-21 466
0cdb319c9ee8e6 David Howells 2021-10-21 467 pos = cachefiles_inject_read_error();
0cdb319c9ee8e6 David Howells 2021-10-21 468 if (pos == 0)
0cdb319c9ee8e6 David Howells 2021-10-21 469 pos = vfs_llseek(file, *_start, SEEK_HOLE);
0cdb319c9ee8e6 David Howells 2021-10-21 470 if (pos < 0 && pos >= (loff_t)-MAX_ERRNO) {
0cdb319c9ee8e6 David Howells 2021-10-21 471 trace_cachefiles_io_error(object, file_inode(file), pos,
0cdb319c9ee8e6 David Howells 2021-10-21 472 cachefiles_trace_seek_error);
0cdb319c9ee8e6 David Howells 2021-10-21 473 return pos;
0cdb319c9ee8e6 David Howells 2021-10-21 474 }
0cdb319c9ee8e6 David Howells 2021-10-21 475 if ((u64)pos >= (u64)*_start + *_len)
0cdb319c9ee8e6 David Howells 2021-10-21 476 return 0; /* Fully allocated */
0cdb319c9ee8e6 David Howells 2021-10-21 477
0cdb319c9ee8e6 David Howells 2021-10-21 478 /* Partially allocated, but insufficient space: cull. */
0cdb319c9ee8e6 David Howells 2021-10-21 479 pos = cachefiles_inject_remove_error();
0cdb319c9ee8e6 David Howells 2021-10-21 480 if (pos == 0)
0cdb319c9ee8e6 David Howells 2021-10-21 481 ret = vfs_fallocate(file, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
0cdb319c9ee8e6 David Howells 2021-10-21 482 *_start, *_len);
"ret" not set on else path.
0cdb319c9ee8e6 David Howells 2021-10-21 @483 if (ret < 0) {
0cdb319c9ee8e6 David Howells 2021-10-21 484 trace_cachefiles_io_error(object, file_inode(file), ret,
0cdb319c9ee8e6 David Howells 2021-10-21 485 cachefiles_trace_fallocate_error);
0cdb319c9ee8e6 David Howells 2021-10-21 486 cachefiles_io_error_obj(object,
0cdb319c9ee8e6 David Howells 2021-10-21 487 "CacheFiles: fallocate failed (%d)\n", ret);
0cdb319c9ee8e6 David Howells 2021-10-21 488 ret = -EIO;
0cdb319c9ee8e6 David Howells 2021-10-21 489 }
0cdb319c9ee8e6 David Howells 2021-10-21 490
0cdb319c9ee8e6 David Howells 2021-10-21 491 return ret;
0cdb319c9ee8e6 David Howells 2021-10-21 492
0cdb319c9ee8e6 David Howells 2021-10-21 493 check_space:
0cdb319c9ee8e6 David Howells 2021-10-21 494 return cachefiles_has_space(cache, 0, *_len / PAGE_SIZE);
0cdb319c9ee8e6 David Howells 2021-10-21 495 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx