From patchwork Mon May 30 21:19:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Trofimovich X-Patchwork-Id: 830942 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4ULK2LW005664 for ; Mon, 30 May 2011 21:20:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754091Ab1E3VT5 (ORCPT ); Mon, 30 May 2011 17:19:57 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:54914 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753986Ab1E3VT4 (ORCPT ); Mon, 30 May 2011 17:19:56 -0400 Received: from gentoo.org (unknown [178.125.169.231]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: slyfox) by smtp.gentoo.org (Postfix) with ESMTPSA id 7215C1B4006; Mon, 30 May 2011 21:19:54 +0000 (UTC) Received: by gentoo.org (sSMTP sendmail emulation); Tue, 31 May 2011 00:19:49 +0300 From: Sergei Trofimovich To: Chris Mason Cc: linux-btrfs@vger.kernel.org, Sergei Trofimovich Subject: [PATCH 4/9] mkfs.btrfs: return some defined value instead of garbage when lookup checksum Date: Tue, 31 May 2011 00:19:03 +0300 Message-Id: <1306790348-9553-5-git-send-email-slyfox@gentoo.org> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1306790348-9553-1-git-send-email-slyfox@gentoo.org> References: <1306790348-9553-1-git-send-email-slyfox@gentoo.org> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 30 May 2011 21:20:02 +0000 (UTC) ==31873== Command: ./mkfs.btrfs -r /some/root/ ==31873== Parent PID: 31872 ==31873== ==31873== Conditional jump or move depends on uninitialised value(s) ==31873== at 0x42C3D0: add_file_items (mkfs.c:792) ==31873== by 0x42CAB3: traverse_directory (mkfs.c:948) ==31873== by 0x42CF11: make_image (mkfs.c:1047) ==31873== by 0x42DE53: main (mkfs.c:1401) ==31873== Uninitialised value was created by a stack allocation ==31873== at 0x41B1B1: btrfs_csum_file_block (file-item.c:195) 'ret' value was not initialized for 'found' branch. The same fix sits in kernel: > commit 639cb58675ce9b507eed9c3d6b3335488079b21a > Author: Chris Mason > Date: Thu Aug 28 06:15:25 2008 -0400 > > Btrfs: Fix variable init during csum creation > > Signed-off-by: Chris Mason Signed-off-by: Sergei Trofimovich --- file-item.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/file-item.c b/file-item.c index 9732282..47f6ad2 100644 --- a/file-item.c +++ b/file-item.c @@ -218,6 +218,7 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans, item = btrfs_lookup_csum(trans, root, path, bytenr, 1); if (!IS_ERR(item)) { leaf = path->nodes[0]; + ret = 0; goto found; } ret = PTR_ERR(item);