From patchwork Thu Aug 16 07:57:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Sheng-Hui X-Patchwork-Id: 1330221 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 26130DF280 for ; Thu, 16 Aug 2012 07:57:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755491Ab2HPH5g (ORCPT ); Thu, 16 Aug 2012 03:57:36 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]:56042 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752507Ab2HPH5f (ORCPT ); Thu, 16 Aug 2012 03:57:35 -0400 Received: by obbuo13 with SMTP id uo13so3331605obb.19 for ; Thu, 16 Aug 2012 00:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=tj69U2avW0zWtm6VUuCRFkLhO7rwRwhDq4P7xqlD2Ik=; b=wp4WAW++thMZetp0IRt+9l7NSD4uS3Q68c21c/vbNL2uTph2+95bCqHbGYDMH6nco9 sA5fq1WH86ekJkb+cgOS4R2k+dYmYK3DiY+JSDQoDHUEfpYbocsHNqmAyzoWzoHrv6pc Vn6HVj50m+DXS91XGRLP0cYFAer/o68ISttvmM+zE6y92o3nCWAReDLF9duKw+vlIO47 F58AuVXunrcSJwW6gOzF62MBFosjhtWuPAB9cAwzqyqAggOuSxElzGL4HCUmg4E/c0Po vUg0vcHmbBGguYrhzygxg8jNSfncj5jOfuraRN87ZRi/fq7v4IREIsMRH+FVLTvLvfce l8xQ== Received: by 10.182.85.8 with SMTP id d8mr202129obz.70.1345103855464; Thu, 16 Aug 2012 00:57:35 -0700 (PDT) Received: from [9.115.120.149] ([202.108.130.138]) by mx.google.com with ESMTPS id d4sm3513397obx.3.2012.08.16.00.57.33 (version=SSLv3 cipher=OTHER); Thu, 16 Aug 2012 00:57:34 -0700 (PDT) Message-ID: <502CA7E6.8020004@gmail.com> Date: Thu, 16 Aug 2012 15:57:26 +0800 From: Wang Sheng-Hui User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 MIME-Version: 1.0 To: chris.mason@fusionio.com, linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: add malloc check in transaction.h/btrfs_start_transaction Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org For malloc may fail, we should check it before assign values to the fields of struct btrfs_trans_handle *h. Signed-off-by: Wang Sheng-Hui --- transaction.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/transaction.h b/transaction.h index a1070e0..d4e42a1 100644 --- a/transaction.h +++ b/transaction.h @@ -32,7 +32,12 @@ static inline struct btrfs_trans_handle * btrfs_start_transaction(struct btrfs_root *root, int num_blocks) { struct btrfs_fs_info *fs_info = root->fs_info; + struct btrfs_trans_handle *h = malloc(sizeof(*h)); + if (!h) { + BUG(); + return NULL; + } BUG_ON(root->commit_root); BUG_ON(fs_info->running_transaction);