[bug report] fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode()

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

 



Hello Tetsuo Handa,

The patch 81b21c0f0138: "fs: hfsplus: remove WARN_ON() from
hfsplus_cat_{read,write}_inode()" from Apr 11, 2023, leads to the
following Smatch static checker warning:

	fs/hfsplus/inode.c:596 hfsplus_cat_write_inode()
	warn: missing error code here? 'hfsplus_find_cat()' failed. 'res' = '0'

fs/hfsplus/inode.c
    577 int hfsplus_cat_write_inode(struct inode *inode)
    578 {
    579         struct inode *main_inode = inode;
    580         struct hfs_find_data fd;
    581         hfsplus_cat_entry entry;
    582         int res = 0;
    583 
    584         if (HFSPLUS_IS_RSRC(inode))
    585                 main_inode = HFSPLUS_I(inode)->rsrc_inode;
    586 
    587         if (!main_inode->i_nlink)
    588                 return 0;
    589 
    590         if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb)->cat_tree, &fd))
    591                 /* panic? */
    592                 return -EIO;
    593 
    594         if (hfsplus_find_cat(main_inode->i_sb, main_inode->i_ino, &fd))
    595                 /* panic? */
--> 596                 goto out;

res = -EIO?

    597 
    598         if (S_ISDIR(main_inode->i_mode)) {
    599                 struct hfsplus_cat_folder *folder = &entry.folder;
    600 
    601                 if (fd.entrylength < sizeof(struct hfsplus_cat_folder)) {
    602                         pr_err("bad catalog folder entry\n");
    603                         res = -EIO;
    604                         goto out;
    605                 }
    606                 hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
    607                                         sizeof(struct hfsplus_cat_folder));
    608                 /* simple node checks? */
    609                 hfsplus_cat_set_perms(inode, &folder->permissions);
    610                 folder->access_date = hfsp_ut2mt(inode->i_atime);
    611                 folder->content_mod_date = hfsp_ut2mt(inode->i_mtime);
    612                 folder->attribute_mod_date = hfsp_ut2mt(inode->i_ctime);
    613                 folder->valence = cpu_to_be32(inode->i_size - 2);
    614                 if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) {
    615                         folder->subfolders =
    616                                 cpu_to_be32(HFSPLUS_I(inode)->subfolders);
    617                 }
    618                 hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
    619                                          sizeof(struct hfsplus_cat_folder));
    620         } else if (HFSPLUS_IS_RSRC(inode)) {
    621                 struct hfsplus_cat_file *file = &entry.file;
    622                 hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
    623                                sizeof(struct hfsplus_cat_file));
    624                 hfsplus_inode_write_fork(inode, &file->rsrc_fork);
    625                 hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
    626                                 sizeof(struct hfsplus_cat_file));
    627         } else {
    628                 struct hfsplus_cat_file *file = &entry.file;
    629 
    630                 if (fd.entrylength < sizeof(struct hfsplus_cat_file)) {
    631                         pr_err("bad catalog file entry\n");
    632                         res = -EIO;
    633                         goto out;
    634                 }
    635                 hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
    636                                         sizeof(struct hfsplus_cat_file));
    637                 hfsplus_inode_write_fork(inode, &file->data_fork);
    638                 hfsplus_cat_set_perms(inode, &file->permissions);
    639                 if (HFSPLUS_FLG_IMMUTABLE &
    640                                 (file->permissions.rootflags |
    641                                         file->permissions.userflags))
    642                         file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED);
    643                 else
    644                         file->flags &= cpu_to_be16(~HFSPLUS_FILE_LOCKED);
    645                 file->access_date = hfsp_ut2mt(inode->i_atime);
    646                 file->content_mod_date = hfsp_ut2mt(inode->i_mtime);
    647                 file->attribute_mod_date = hfsp_ut2mt(inode->i_ctime);
    648                 hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
    649                                          sizeof(struct hfsplus_cat_file));
    650         }
    651 
    652         set_bit(HFSPLUS_I_CAT_DIRTY, &HFSPLUS_I(inode)->flags);
    653 out:
    654         hfs_find_exit(&fd);
    655         return res;
    656 }

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