From patchwork Thu Sep 6 06:18:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 1412071 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 10CD83FC85 for ; Thu, 6 Sep 2012 06:18:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977Ab2IFGSr (ORCPT ); Thu, 6 Sep 2012 02:18:47 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:35231 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751379Ab2IFGSr (ORCPT ); Thu, 6 Sep 2012 02:18:47 -0400 Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id BAEE03EE0C1 for ; Thu, 6 Sep 2012 15:18:45 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id A127645DEBC for ; Thu, 6 Sep 2012 15:18:45 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id 89D9245DEB6 for ; Thu, 6 Sep 2012 15:18:45 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 73F9A1DB8041 for ; Thu, 6 Sep 2012 15:18:45 +0900 (JST) Received: from m1000.s.css.fujitsu.com (m1000.s.css.fujitsu.com [10.240.81.136]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 2B1761DB803B for ; Thu, 6 Sep 2012 15:18:45 +0900 (JST) Received: from m1000.css.fujitsu.com (m1000 [127.0.0.1]) by m1000.s.css.fujitsu.com (Postfix) with ESMTP id F2AAF60F36; Thu, 6 Sep 2012 15:18:44 +0900 (JST) Received: from FM-323941448.jp.fujitsu.com (unknown [10.124.101.87]) by m1000.s.css.fujitsu.com (Postfix) with SMTP id BFAC660F21; Thu, 6 Sep 2012 15:18:44 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-Id: <201209060618.AA00004@FM-323941448.jp.fujitsu.com> From: Tsutomu Itoh Date: Thu, 06 Sep 2012 15:18:10 +0900 To: chris.mason@fusionio.com Cc: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: check return value of ulist_alloc() properly MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org ulist_alloc() has the possibility of returning NULL. So, it is necessary to check the return value. Signed-off-by: Tsutomu Itoh --- fs/btrfs/qgroup.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 38b42e7..7aee652 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1473,6 +1473,10 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) * be exceeded */ ulist = ulist_alloc(GFP_ATOMIC); + if (!ulist) { + ret = -ENOMEM; + goto out; + } ulist_add(ulist, qgroup->qgroupid, (unsigned long)qgroup, GFP_ATOMIC); ULIST_ITER_INIT(&uiter); while ((unode = ulist_next(ulist, &uiter))) { @@ -1545,6 +1549,10 @@ void btrfs_qgroup_free(struct btrfs_root *root, u64 num_bytes) goto out; ulist = ulist_alloc(GFP_ATOMIC); + if (!ulist) { + btrfs_std_error(fs_info, -ENOMEM); + goto out; + } ulist_add(ulist, qgroup->qgroupid, (unsigned long)qgroup, GFP_ATOMIC); ULIST_ITER_INIT(&uiter); while ((unode = ulist_next(ulist, &uiter))) {