From patchwork Sat Mar 15 11:46:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pandit X-Patchwork-Id: 3836861 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 031039F1CD for ; Sat, 15 Mar 2014 11:46:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2000201B4 for ; Sat, 15 Mar 2014 11:46:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7A797200CF for ; Sat, 15 Mar 2014 11:46:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753333AbaCOLqU (ORCPT ); Sat, 15 Mar 2014 07:46:20 -0400 Received: from nbl-ex10-fe02.nebula.fi ([188.117.32.122]:54157 "EHLO ex10.nebula.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752864AbaCOLqT (ORCPT ); Sat, 15 Mar 2014 07:46:19 -0400 Received: from localhost.localdomain (88.195.158.30) by ex10.nebula.fi (188.117.32.115) with Microsoft SMTP Server (TLS) id 14.3.174.1; Sat, 15 Mar 2014 13:53:00 +0200 Date: Sat, 15 Mar 2014 13:46:15 +0200 From: Rakesh Pandit To: Subject: [PATCH] Btrfs-progs: return with -ENOMEM if malloc fails Message-ID: <20140315114613.GA8420@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Originating-IP: [88.195.158.30] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Prevent segfault if memory allocation fails for sargs in get_df (cmds-filesystem.c). Signed-off-by: Rakesh Pandit --- cmds-filesystem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index c9e27fc..7eb6e9d 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -146,7 +146,7 @@ static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret) sargs = malloc(sizeof(struct btrfs_ioctl_space_args) + (count * sizeof(struct btrfs_ioctl_space_info))); if (!sargs) - ret = -ENOMEM; + return -ENOMEM; sargs->space_slots = count; sargs->total_spaces = 0;