From patchwork Thu May 2 02:46:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lin X-Patchwork-Id: 2509881 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 197DB3FD85 for ; Thu, 2 May 2013 02:48:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758006Ab3EBCsV (ORCPT ); Wed, 1 May 2013 22:48:21 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:34540 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757234Ab3EBCsT (ORCPT ); Wed, 1 May 2013 22:48:19 -0400 Received: by mail-pd0-f173.google.com with SMTP id v10so90034pde.4 for ; Wed, 01 May 2013 19:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:subject:date:message-id:x-mailer; bh=hhsfOpRKQboz6dLlAkPXuSRpPD+hsrliDAgZVCT7ChA=; b=xhfHRDgcHJ/YclIM0RGWnQYxNBcO43hNNo8WRc6c0CEGLWaZkyrRldmFagH2vMrNAO sEMLgFK4m4OJzJsC3w2ZujtX0KZ5kMyX34ADZFzTx246fsmcrsF4VvROmHzm2Pm5uTTP t5Cz1V8wotsb8sZOjBXXWwSXV6DOry2Kxx7qv7A/emVsZ+/ON1RHZN6sv4G5z2HVeQYM kQ6M6QTdsAY7ovKCMPP9SZXRj1r7CT/i2Flq4WZwoie4E8OmNV3891BIvwW6fO6zPtz3 /tXiCucRyUfVPklTH/BKHwb7DWNwN/4oirKEszu2F1Jn+k2HOHLzd2JS4/hMWBwJGOJm 8z6g== X-Received: by 10.68.240.2 with SMTP id vw2mr6694997pbc.159.1367462899364; Wed, 01 May 2013 19:48:19 -0700 (PDT) Received: from localhost.localdomain ([220.248.17.187]) by mx.google.com with ESMTPSA id be7sm6101800pad.20.2013.05.01.19.48.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 01 May 2013 19:48:18 -0700 (PDT) From: Lin Ming To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: fix segfault in walk_down_tree Date: Thu, 2 May 2013 10:46:43 +0800 Message-Id: <1367462803-6630-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 walk_down_tree will fault when read_tree_block fails with NULL returned. Signed-off-by: Lin Ming --- cmds-check.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index 12192fa..e4435d5 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -1256,6 +1256,8 @@ 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) + goto out; } *level = *level - 1;