* [PATCH] Btrfs-progs: fail gracefully on error from open_ctree()
@ 2011-11-01 21:47 Ilya Dryomov
2011-12-12 14:40 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: Ilya Dryomov @ 2011-11-01 21:47 UTC (permalink / raw)
To: linux-btrfs; +Cc: Chris Mason, Hugo Mills, idryomov
Error checking block got moved mistakenly exposing us to a potential
segmentation fault.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
mkfs.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/mkfs.c b/mkfs.c
index e3ced19..a6f6b1f 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1328,7 +1328,12 @@ int main(int ac, char **av)
fprintf(stderr, "error during mkfs %d\n", ret);
exit(1);
}
+
root = open_ctree(file, 0, O_RDWR);
+ if (!root) {
+ fprintf(stderr, "ctree init failed\n");
+ return -1;
+ }
root->fs_info->alloc_start = alloc_start;
ret = make_root_dir(root, mixed);
@@ -1343,10 +1348,6 @@ int main(int ac, char **av)
goto raid_groups;
btrfs_register_one_device(file);
- if (!root) {
- fprintf(stderr, "ctree init failed\n");
- return -1;
- }
zero_end = 1;
while(ac-- > 0) {
--
1.7.6.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs-progs: fail gracefully on error from open_ctree()
2011-11-01 21:47 [PATCH] Btrfs-progs: fail gracefully on error from open_ctree() Ilya Dryomov
@ 2011-12-12 14:40 ` David Sterba
2011-12-12 18:07 ` Ilya Dryomov
0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2011-12-12 14:40 UTC (permalink / raw)
To: Ilya Dryomov; +Cc: linux-btrfs, Chris Mason, Hugo Mills
On Tue, Nov 01, 2011 at 11:47:22PM +0200, Ilya Dryomov wrote:
> --- a/mkfs.c
> +++ b/mkfs.c
> @@ -1328,7 +1328,12 @@ int main(int ac, char **av)
> fprintf(stderr, "error during mkfs %d\n", ret);
> exit(1);
> }
> +
> root = open_ctree(file, 0, O_RDWR);
> + if (!root) {
> + fprintf(stderr, "ctree init failed\n");
> + return -1;
I know you just moved the code, but this should be exit(1), same as the
rest of the function does
> + }
> root->fs_info->alloc_start = alloc_start;
>
> ret = make_root_dir(root, mixed);
> @@ -1343,10 +1348,6 @@ int main(int ac, char **av)
> goto raid_groups;
>
> btrfs_register_one_device(file);
> - if (!root) {
> - fprintf(stderr, "ctree init failed\n");
> - return -1;
> - }
>
> zero_end = 1;
> while(ac-- > 0) {
david
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs-progs: fail gracefully on error from open_ctree()
2011-12-12 14:40 ` David Sterba
@ 2011-12-12 18:07 ` Ilya Dryomov
0 siblings, 0 replies; 3+ messages in thread
From: Ilya Dryomov @ 2011-12-12 18:07 UTC (permalink / raw)
To: David Sterba; +Cc: linux-btrfs, Chris Mason, Hugo Mills
On Mon, Dec 12, 2011 at 03:40:19PM +0100, David Sterba wrote:
> On Tue, Nov 01, 2011 at 11:47:22PM +0200, Ilya Dryomov wrote:
> > --- a/mkfs.c
> > +++ b/mkfs.c
> > @@ -1328,7 +1328,12 @@ int main(int ac, char **av)
> > fprintf(stderr, "error during mkfs %d\n", ret);
> > exit(1);
> > }
> > +
> > root = open_ctree(file, 0, O_RDWR);
> > + if (!root) {
> > + fprintf(stderr, "ctree init failed\n");
> > + return -1;
>
> I know you just moved the code, but this should be exit(1), same as the
> rest of the function does
I updated the patch.
Thanks,
Ilya
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-12-12 18:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-01 21:47 [PATCH] Btrfs-progs: fail gracefully on error from open_ctree() Ilya Dryomov
2011-12-12 14:40 ` David Sterba
2011-12-12 18:07 ` Ilya Dryomov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).