All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode()
@ 2023-05-04 11:14 Dan Carpenter
  2023-05-04 11:34 ` Tetsuo Handa
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2023-05-04 11:14 UTC (permalink / raw)
  To: penguin-kernel; +Cc: linux-fsdevel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode()
  2023-05-04 11:14 [bug report] fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode() Dan Carpenter
@ 2023-05-04 11:34 ` Tetsuo Handa
  2023-05-04 14:39   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Tetsuo Handa @ 2023-05-04 11:34 UTC (permalink / raw)
  To: Dan Carpenter, Christian Brauner; +Cc: linux-fsdevel

On 2023/05/04 20:14, Dan Carpenter wrote:
> 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'

It has been returning 0 since commit 1da177e4c3f4 ("Linux-2.6.12-rc2").
I guess that the author of this filesystem was wondering what to do in that case.
Since this filesystem is orphaned, I don't know whom to ask.
If you think returning an error is better, please submit as a patch.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode()
  2023-05-04 11:34 ` Tetsuo Handa
@ 2023-05-04 14:39   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-05-04 14:39 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: Christian Brauner, linux-fsdevel

On Thu, May 04, 2023 at 08:34:27PM +0900, Tetsuo Handa wrote:
> On 2023/05/04 20:14, Dan Carpenter wrote:
> > 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'
> 
> It has been returning 0 since commit 1da177e4c3f4 ("Linux-2.6.12-rc2").
> I guess that the author of this filesystem was wondering what to do in that case.
> Since this filesystem is orphaned, I don't know whom to ask.
> If you think returning an error is better, please submit as a patch.

Returning an error is probably correct, but I can't test it.  Let's just
leave the warning until someone comes who knows for sure.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-04 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04 11:14 [bug report] fs: hfsplus: remove WARN_ON() from hfsplus_cat_{read,write}_inode() Dan Carpenter
2023-05-04 11:34 ` Tetsuo Handa
2023-05-04 14:39   ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.