Btrfs: return code checking

Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/random-test.c b/fs/btrfs/random-test.c
index 7078263..cebaf64 100644
--- a/fs/btrfs/random-test.c
+++ b/fs/btrfs/random-test.c
@@ -134,7 +134,7 @@
 		return ret;
 	ret = search_slot(root, &key, &path, 0);
 	release_path(root, &path);
-	if (ret == 0)
+	if (ret <= 0)
 		goto error;
 	return 0;
 error:
@@ -153,12 +153,17 @@
 	int ret;
 	int slot;
 	int i;
+
 	key.offset = 0;
 	key.flags = 0;
 	key.objectid = (unsigned long)-1;
 	while(1) {
 		init_path(&path);
 		ret = search_slot(root, &key, &path, 0);
+		if (ret < 0) {
+			release_path(root, &path);
+			return ret;
+		}
 		slot = path.slots[0];
 		if (ret != 0) {
 			if (slot == 0) {