[PATCH] gfs2: Set error on error path

From: Deepak R Varma
Date: Fri Sep 29 2023 - 02:15:09 EST


Set the error variable inside the error path on failure. Saves
unnecessary variable assignment during normal execution.

Signed-off-by: Deepak R Varma <drv@xxxxxxxxx>
---
fs/gfs2/bmap.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index ef7017fb6951..93bd8ea34444 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -162,9 +162,10 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip)

down_write(&ip->i_rw_mutex);
page = grab_cache_page(inode->i_mapping, 0);
- error = -ENOMEM;
- if (!page)
+ if (!page) {
+ error = -ENOMEM;
goto out;
+ }
error = __gfs2_unstuff_inode(ip, page);
unlock_page(page);
put_page(page);
--
2.39.2