From patchwork Fri May 3 03:51:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lin X-Patchwork-Id: 2512661 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CF96CDF215 for ; Thu, 2 May 2013 15:52:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759656Ab3EBPwA (ORCPT ); Thu, 2 May 2013 11:52:00 -0400 Received: from mail-pb0-f42.google.com ([209.85.160.42]:44458 "EHLO mail-pb0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759572Ab3EBPv7 (ORCPT ); Thu, 2 May 2013 11:51:59 -0400 Received: by mail-pb0-f42.google.com with SMTP id up7so416274pbc.29 for ; Thu, 02 May 2013 08:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer; bh=2723DRm5TsFeXIJwksG7oXawjlbp36HAlJ103zLVLdI=; b=sbtim/gGUJqJ7gWYWm30yO5G55IyWiRYbmWdXWFx1QTMHXglCQjDWqZ9C2hefJTiPO do7DyOAAxrCk3cuJLlELgctPDZawgFjoS1gBRbVlX9XqxPxM8tZFgqhIzRY780oheFJp DHJ0mEaCDQeL4Rjyq0Pxs+1lBw8pNmKCHDA7xr3HrebD2DAiomSo+QbFGYSvfR4B63rO SgK85m5e3V3LGYKNGaZqp18X7rB/572ZFhzOA3qB6NhOvAZTm2QO1kWLBJmpdFZUyCLJ PaaVu7T72x4PD0/kTzmFY/pTiFcqAm3Er/OlaqIlef3HGUtxgoqdSRy9R68Q0PiKdpTO yJoQ== X-Received: by 10.66.160.104 with SMTP id xj8mr10464933pab.3.1367509919126; Thu, 02 May 2013 08:51:59 -0700 (PDT) Received: from localhost.localdomain ([222.67.39.114]) by mx.google.com with ESMTPSA id ux10sm8799204pab.1.2013.05.02.08.51.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 May 2013 08:51:58 -0700 (PDT) From: Lin Ming To: linux-btrfs@vger.kernel.org Cc: Eric Sandeen Subject: [PATCH] btrfs-progs: pass up return value of walk_down_tree Date: Thu, 2 May 2013 23:51:38 -0400 Message-Id: <1367553098-6315-1-git-send-email-mlin@kernel.org> X-Mailer: git-send-email 1.7.2.5 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Pass up return value of walk_down_tree, so the caller can handle it. This also fixes a segfault when read_tree_block fails with NULL returned. Signed-off-by: Lin Ming --- cmds-check.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index 12192fa..7a51627 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -1201,7 +1201,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, struct extent_buffer *next; struct extent_buffer *cur; u32 blocksize; - int ret; + int ret, err = 0; u64 refs; WARN_ON(*level < 0); @@ -1209,14 +1209,18 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, ret = btrfs_lookup_extent_info(NULL, root, path->nodes[*level]->start, path->nodes[*level]->len, &refs, NULL); - if (ret < 0) + if (ret < 0) { + err = ret; goto out; + } if (refs > 1) { ret = enter_shared_node(root, path->nodes[*level]->start, refs, wc, *level); - if (ret > 0) + if (ret > 0) { + err = ret; goto out; + } } while (*level >= 0) { @@ -1256,6 +1260,10 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, reada_walk_down(root, cur, path->slots[*level]); next = read_tree_block(root, bytenr, blocksize, ptr_gen); + if (!next) { + err = -EIO; + goto out; + } } *level = *level - 1; @@ -1265,7 +1273,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, } out: path->slots[*level] = btrfs_header_nritems(path->nodes[*level]); - return 0; + return err; } static int walk_up_tree(struct btrfs_root *root, struct btrfs_path *path,