[bug report] buffer: hoist GFP flags from grow_dev_page() to __getblk_gfp()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Matthew Wilcox (Oracle),

The patch a3c38500d469: "buffer: hoist GFP flags from grow_dev_page()
to __getblk_gfp()" from Sep 14, 2023 (linux-next), leads to the
following Smatch static checker warning:

	fs/buffer.c:1065 grow_dev_page()
	warn: NEW missing error code 'ret'

fs/buffer.c
    1037 static int
    1038 grow_dev_page(struct block_device *bdev, sector_t block,
    1039               pgoff_t index, int size, int sizebits, gfp_t gfp)
    1040 {
    1041         struct inode *inode = bdev->bd_inode;
    1042         struct folio *folio;
    1043         struct buffer_head *bh;
    1044         sector_t end_block;
    1045         int ret = 0;
    1046 
    1047         folio = __filemap_get_folio(inode->i_mapping, index,
    1048                         FGP_LOCK | FGP_ACCESSED | FGP_CREAT, gfp);
    1049         if (IS_ERR(folio))
    1050                 return PTR_ERR(folio);
    1051 
    1052         bh = folio_buffers(folio);
    1053         if (bh) {
    1054                 if (bh->b_size == size) {
    1055                         end_block = folio_init_buffers(folio, bdev,
    1056                                         (sector_t)index << sizebits, size);
    1057                         goto done;
    1058                 }
    1059                 if (!try_to_free_buffers(folio))
    1060                         goto failed;
    1061         }
    1062 
    1063         bh = folio_alloc_buffers(folio, size, gfp | __GFP_ACCOUNT);
    1064         if (!bh)
--> 1065                 goto failed;

Should this be an error code?  It's kind of complicated because I think
the other goto failed path deliberately returns zero?

    1066 
    1067         /*
    1068          * Link the folio to the buffers and initialise them.  Take the
    1069          * lock to be atomic wrt __find_get_block(), which does not
    1070          * run under the folio lock.
    1071          */
    1072         spin_lock(&inode->i_mapping->private_lock);
    1073         link_dev_buffers(folio, bh);
    1074         end_block = folio_init_buffers(folio, bdev,
    1075                         (sector_t)index << sizebits, size);
    1076         spin_unlock(&inode->i_mapping->private_lock);
    1077 done:
    1078         ret = (block < end_block) ? 1 : -ENXIO;
    1079 failed:
    1080         folio_unlock(folio);
    1081         folio_put(folio);
    1082         return ret;
    1083 }

regards,
dan carpenter



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux