mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: ocfs2: Check status values
@ 2023-10-09 14:11 Artem Chernyshev
  2023-10-10  1:20 ` Joseph Qi
  0 siblings, 1 reply; 2+ messages in thread
From: Artem Chernyshev @ 2023-10-09 14:11 UTC (permalink / raw)
  To: Joel Becker, Mark Fasheh
  Cc: Artem Chernyshev, Joseph Qi, Kurt Hackel, ocfs2-devel,
	linux-kernel, lvc-project

Test return values before overwriting.

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

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
---
 fs/ocfs2/namei.c       | 8 ++++++++
 fs/ocfs2/quota_local.c | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 5cd6d7771cea..836c4279a979 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -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);
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index dfaae1e52412..e09842fc9d4d 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -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);
-- 
2.37.3


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

* Re: [PATCH] fs: ocfs2: Check status values
  2023-10-09 14:11 [PATCH] fs: ocfs2: Check status values Artem Chernyshev
@ 2023-10-10  1:20 ` Joseph Qi
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Qi @ 2023-10-10  1:20 UTC (permalink / raw)
  To: Artem Chernyshev, Joel Becker, Mark Fasheh, akpm
  Cc: Kurt Hackel, ocfs2-devel, linux-kernel, lvc-project



On 10/9/23 10:11 PM, Artem Chernyshev wrote:
> Test return values before overwriting.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>

Looks good.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/namei.c       | 8 ++++++++
>  fs/ocfs2/quota_local.c | 4 ++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 5cd6d7771cea..836c4279a979 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -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);
> diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
> index dfaae1e52412..e09842fc9d4d 100644
> --- a/fs/ocfs2/quota_local.c
> +++ b/fs/ocfs2/quota_local.c
> @@ -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);

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

end of thread, other threads:[~2023-10-10  1:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-09 14:11 [PATCH] fs: ocfs2: Check status values Artem Chernyshev
2023-10-10  1:20 ` Joseph Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®