linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs-progs: seg fault in get_label_unmounted
@ 2012-08-15  8:29 Anand jain
  2012-08-22 13:47 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Anand jain @ 2012-08-15  8:29 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Anand Jain

From: Anand Jain <anand.jain@oracle.com>

btrfs f l /
No valid Btrfs found on /
Segmentation fault (core dumped)

open_ctree can return NULL, we need to check that.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 btrfslabel.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/btrfslabel.c b/btrfslabel.c
index bf73802..cb142b0 100644
--- a/btrfslabel.c
+++ b/btrfslabel.c
@@ -67,7 +67,7 @@ static void change_label_unmounted(char *dev, char *nLabel)
        close_ctree(root);
 }
 
-static void get_label_unmounted(char *dev)
+int get_label_unmounted(char *dev)
 {
        struct btrfs_root *root;
 
@@ -76,10 +76,14 @@ static void get_label_unmounted(char *dev)
         */
        root = open_ctree(dev, 0, 0);
 
+       if(!root)
+         return -1;
+
        fprintf(stdout, "%s\n", root->fs_info->super_copy.label);
 
        /* Now we close it since we are done. */
        close_ctree(root);
+       return 0;
 }
 
 int get_label(char *btrfs_dev)
@@ -98,8 +102,8 @@ int get_label(char *btrfs_dev)
 	       fprintf(stderr, "FATAL: the filesystem has to be unmounted\n");
 	       return -2;
 	}
-	get_label_unmounted(btrfs_dev);
-	return 0;
+	ret = get_label_unmounted(btrfs_dev);
+	return ret;
 }
 
 
-- 
1.7.1


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

* Re: [PATCH] Btrfs-progs: seg fault in get_label_unmounted
  2012-08-15  8:29 [PATCH] Btrfs-progs: seg fault in get_label_unmounted Anand jain
@ 2012-08-22 13:47 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2012-08-22 13:47 UTC (permalink / raw)
  To: Anand jain; +Cc: linux-btrfs

On Wed, Aug 15, 2012 at 04:29:53PM +0800, Anand jain wrote:
> From: Anand Jain <anand.jain@oracle.com>
> 
> btrfs f l /
> No valid Btrfs found on /
> Segmentation fault (core dumped)

Patches fixing this have been sent like 4 times, last one was from
Alexander's 'btrfs prop', that modified it a bit more (to return the
label instead of printing it).

http://permalink.gmane.org/gmane.comp.file-systems.btrfs/18287

while Danny fixes more instances of unhandled error code from open_ctree

http://permalink.gmane.org/gmane.comp.file-systems.btrfs/15305

JFYI,
david

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

end of thread, other threads:[~2012-08-22 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-15  8:29 [PATCH] Btrfs-progs: seg fault in get_label_unmounted Anand jain
2012-08-22 13:47 ` David Sterba

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).