Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: pratikshinde320@gmail.com (Pratik Shinde)
Subject: [PATCH] erofs-utils: Add missing error code handling.
Date: Wed, 24 Jul 2019 01:34:29 +0530	[thread overview]
Message-ID: <20190723200429.7132-1-pratikshinde320@gmail.com> (raw)

Handling error conditions that are missing in few scenarios.

Signed-off-by: Pratik Shinde <pratikshinde320 at gmail.com>
---
 lib/inode.c | 10 ++++++++--
 mkfs/main.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index 179aa26..08d38c0 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -752,8 +752,14 @@ struct erofs_inode *erofs_mkfs_build_tree(struct erofs_inode *dir)
 	}
 	closedir(_dir);
 
-	erofs_prepare_dir_file(dir);
-	erofs_prepare_inode_buffer(dir);
+	ret = erofs_prepare_dir_file(dir);
+	if(!ret)
+		goto err_closedir;
+
+	ret = erofs_prepare_inode_buffer(dir);
+	if(!ret)
+		goto err_closedir;
+
 	if (IS_ROOT(dir))
 		erofs_fixup_meta_blkaddr(dir);
 
diff --git a/mkfs/main.c b/mkfs/main.c
index 1348587..9c9530d 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -200,18 +200,24 @@ int main(int argc, char **argv)
 	if (err) {
 		if (err == -EINVAL)
 			usage();
-		return 1;
+		return err;
 	}
 
 	err = dev_open(cfg.c_img_path);
 	if (err) {
 		usage();
-		return 1;
+		return err;
 	}
 
 	erofs_show_config();
 
 	sb_bh = erofs_buffer_init();
+	if(IS_ERR(sb_bh)) {
+		err = PTR_ERR(sb_bh);
+		erofs_err("Failed to initialize super block buffer head : %s",
+			  erofs_strerror(err));
+		goto exit;
+	}
 	err = erofs_bh_balloon(sb_bh, EROFS_SUPER_END);
 	if (err < 0) {
 		erofs_err("Failed to balloon erofs_super_block: %s",
-- 
2.9.3

             reply	other threads:[~2019-07-23 20:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 20:04 Pratik Shinde [this message]
2019-07-24  1:34 ` [PATCH] erofs-utils: Add missing error code handling Gao Xiang
2019-07-24  2:11   ` Pratik Shinde
2019-07-24  2:13     ` Gao Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190723200429.7132-1-pratikshinde320@gmail.com \
    --to=pratikshinde320@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox