fs: ocfs2: check status values
authorArtem Chernyshev <artem.chernyshev@red-soft.ru>
Mon, 9 Oct 2023 14:11:11 +0000 (17:11 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 18 Oct 2023 21:43:22 +0000 (14:43 -0700)
Test return values before overwriting.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Link: https://lkml.kernel.org/r/20231009141111.149858-1-artem.chernyshev@red-soft.ru
Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/namei.c
fs/ocfs2/quota_local.c

index 5cd6d77..836c427 100644 (file)
@@ -1597,6 +1597,10 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
        if (update_dot_dot) {
                status = ocfs2_update_entry(old_inode, handle,
                                            &old_inode_dot_dot_res, new_dir);
+               if (status < 0) {
+                       mlog_errno(status);
+                       goto bail;
+               }
                drop_nlink(old_dir);
                if (new_inode) {
                        drop_nlink(new_inode);
@@ -1636,6 +1640,10 @@ static int ocfs2_rename(struct mnt_idmap *idmap,
                                                         INODE_CACHE(old_dir),
                                                         old_dir_bh,
                                                         OCFS2_JOURNAL_ACCESS_WRITE);
+                       if (status < 0) {
+                               mlog_errno(status);
+                               goto bail;
+                       }
                        fe = (struct ocfs2_dinode *) old_dir_bh->b_data;
                        ocfs2_set_links_count(fe, old_dir->i_nlink);
                        ocfs2_journal_dirty(handle, old_dir_bh);
index dfaae1e..e09842f 100644 (file)
@@ -1240,6 +1240,10 @@ int ocfs2_create_local_dquot(struct dquot *dquot)
                                     &od->dq_local_phys_blk,
                                     &pcount,
                                     NULL);
+       if (status < 0) {
+               mlog_errno(status);
+               goto out;
+       }
 
        /* Initialize dquot structure on disk */
        status = ocfs2_local_write_dquot(dquot);