fs/f2fs/data.c:433 __has_merged_page() error: 'target' dereferencing possible ERR_PTR()
PATCH 1/3 fs/f2fs/data.c:433 __has_merged_page() error: 'target' dereferencing possible ERR_PTR()
tree: https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git compression head: 1c310bddebde4e94a780c2b2699a3ac35e166ca9 commit: b49443e5f3aecab358837790dfb5a30fd95a7926 [1/3] f2fs: support data compression
If you fix the issue, kindly add following tag
New smatch warnings:fs/f2fs/data.c:433 __has_merged_page() error: 'target' dereferencing possible ERR_PTR()
Old smatch warnings:fs/f2fs/data.c:2451 f2fs_write_single_data_page() warn: should '(page->index + 1) << 12' be a 64 bit type?
# https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/commit/?id=b49443e5f3aecab358837790dfb5a30fd95a7926
git remote add chao-linux https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git
git remote update chao-linux
git checkout b49443e5f3aecab358837790dfb5a30fd95a7926
vim +/target +433 fs/f2fs/data.c
8648de2c581eed Chao Yu 2019-02-19 413 static bool __has_merged_page(struct bio *bio, struct inode *inode,
bab475c5414e8d Chao Yu 2018-09-27 414 struct page *page, nid_t ino)
0fd785eb931d25 Chao Yu 2016-01-18 415 {
0fd785eb931d25 Chao Yu 2016-01-18 416 struct bio_vec *bvec;
6dc4f100c175dd Ming Lei 2019-02-15 417 struct bvec_iter_all iter_all;
0fd785eb931d25 Chao Yu 2016-01-18 418
8648de2c581eed Chao Yu 2019-02-19 419 if (!bio)
0fd785eb931d25 Chao Yu 2016-01-18 420 return false;
0c3a579758362d Chao Yu 2016-01-18 421
bab475c5414e8d Chao Yu 2018-09-27 422 if (!inode && !page && !ino)
0c3a579758362d Chao Yu 2016-01-18 423 return true;
0fd785eb931d25 Chao Yu 2016-01-18 424
8648de2c581eed Chao Yu 2019-02-19 425 bio_for_each_segment_all(bvec, bio, iter_all) {
b49443e5f3aeca Chao Yu 2019-10-29 426 struct page *target = bvec->bv_page;
0fd785eb931d25 Chao Yu 2016-01-18 427
d2d0727b1654e1 Eric Biggers 2019-05-20 428 if (fscrypt_is_bounce_page(target))
d2d0727b1654e1 Eric Biggers 2019-05-20 429 target = fscrypt_pagecache_page(target);
b49443e5f3aeca Chao Yu 2019-10-29 430 if (f2fs_is_compressed_page(target))
b49443e5f3aeca Chao Yu 2019-10-29 431 target = f2fs_compress_control_page(target);
0fd785eb931d25 Chao Yu 2016-01-18 432
0c3a579758362d Chao Yu 2016-01-18 @433 if (inode && inode == target->mapping->host)
0c3a579758362d Chao Yu 2016-01-18 434 return true;
bab475c5414e8d Chao Yu 2018-09-27 435 if (page && page == target)
bab475c5414e8d Chao Yu 2018-09-27 436 return true;
0c3a579758362d Chao Yu 2016-01-18 437 if (ino && ino == ino_of_node(target))
0fd785eb931d25 Chao Yu 2016-01-18 438 return true;
0fd785eb931d25 Chao Yu 2016-01-18 439 }
0c3a579758362d Chao Yu 2016-01-18 440
0c3a579758362d Chao Yu 2016-01-18 441 return false;
0fd785eb931d25 Chao Yu 2016-01-18 442 }---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 10 lines · Dan Carpenter
tree: https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git compression head: 1c310bddebde4e94a780c2b2699a3ac35e166ca9 commit: b49443e5f3aecab358837790dfb5a30fd95a7926 [1/3] f2fs: support data compressionIf you fix the issue, kindly add following tag
Reported-by kbuild test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>New smatch warnings:
fs/f2fs/data.c:433__has_merged_page()error: 'target' dereferencing possibleERR_PTR()
Thank you for the report, will add error handling in __has_merged_page().
Quoted 3 lines
Old smatch warnings:
fs/f2fs/data.c:2451f2fs_write_single_data_page()warn: should '(page->index+ 1) << 12' be a 64 bit type?
Alright..., this should be a original bug, will fix this in separated patch.
Thanks,
Quoted 43 lines
# https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/commit/?id=b49443e5f3aecab358837790dfb5a30fd95a7926
git remote add chao-linux https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git
git remote update chao-linux
git checkoutb49443e5f3aecab358837790dfb5a30fd95a7926
vim +/target +433fs/f2fs/data.c8648de2c581eed Chao Yu 2019-02-19 413 static bool __has_merged_page(struct bio *bio, struct inode *inode, bab475c5414e8d Chao Yu 2018-09-27 414 struct page *page, nid_t ino) 0fd785eb931d25 Chao Yu 2016-01-18 415 { 0fd785eb931d25 Chao Yu 2016-01-18 416 struct bio_vec *bvec; 6dc4f100c175dd Ming Lei 2019-02-15 417 struct bvec_iter_all iter_all; 0fd785eb931d25 Chao Yu 2016-01-18 418 8648de2c581eed Chao Yu 2019-02-19 419 if (!bio) 0fd785eb931d25 Chao Yu 2016-01-18 420 return false; 0c3a579758362d Chao Yu 2016-01-18 421 bab475c5414e8d Chao Yu 2018-09-27 422 if (!inode && !page && !ino) 0c3a579758362d Chao Yu 2016-01-18 423 return true; 0fd785eb931d25 Chao Yu 2016-01-18 424 8648de2c581eed Chao Yu 2019-02-19 425 bio_for_each_segment_all(bvec, bio, iter_all) { b49443e5f3aeca Chao Yu 2019-10-29 426 struct page *target = bvec->bv_page; 0fd785eb931d25 Chao Yu 2016-01-18 427 d2d0727b1654e1 Eric Biggers 2019-05-20 428 if (fscrypt_is_bounce_page(target)) d2d0727b1654e1 Eric Biggers 2019-05-20 429 target = fscrypt_pagecache_page(target); b49443e5f3aeca Chao Yu 2019-10-29 430 if (f2fs_is_compressed_page(target)) b49443e5f3aeca Chao Yu 2019-10-29 431 target = f2fs_compress_control_page(target); 0fd785eb931d25 Chao Yu 2016-01-18 432 0c3a579758362d Chao Yu 2016-01-18 @433 if (inode && inode == target->mapping->host) 0c3a579758362d Chao Yu 2016-01-18 434 return true; bab475c5414e8d Chao Yu 2018-09-27 435 if (page && page == target) bab475c5414e8d Chao Yu 2018-09-27 436 return true; 0c3a579758362d Chao Yu 2016-01-18 437 if (ino && ino == ino_of_node(target)) 0fd785eb931d25 Chao Yu 2016-01-18 438 return true; 0fd785eb931d25 Chao Yu 2016-01-18 439 } 0c3a579758362d Chao Yu 2016-01-18 440 0c3a579758362d Chao Yu 2016-01-18 441 return false; 0fd785eb931d25 Chao Yu 2016-01-18 442 }---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
.