From patchwork Tue Apr 29 16:01:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 4088261 X-Patchwork-Delegate: dave@jikos.cz Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F27A9BFF02 for ; Tue, 29 Apr 2014 16:02:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 343B0201F5 for ; Tue, 29 Apr 2014 16:02:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52D83201F4 for ; Tue, 29 Apr 2014 16:02:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757840AbaD2QCH (ORCPT ); Tue, 29 Apr 2014 12:02:07 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57267 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756515AbaD2QCG (ORCPT ); Tue, 29 Apr 2014 12:02:06 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 40D1BAC4F for ; Tue, 29 Apr 2014 16:02:06 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 0F985DA935; Tue, 29 Apr 2014 18:02:06 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 05/14] btrfs-progs: zero out structures before calling ioctl Date: Tue, 29 Apr 2014 18:01:18 +0200 Message-Id: <9d1cde36aa9edf28f5dd431a9f6899ca7b309269.1398786620.git.dsterba@suse.cz> X-Mailer: git-send-email 1.9.0 In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Signed-off-by: David Sterba --- cmds-fi-disk_usage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c index 64c85acafd51..067c60078710 100644 --- a/cmds-fi-disk_usage.c +++ b/cmds-fi-disk_usage.c @@ -248,7 +248,7 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path) struct btrfs_ioctl_space_args *sargs = 0, *sargs_orig = 0; int e, ret, count; - sargs_orig = sargs = malloc(sizeof(struct btrfs_ioctl_space_args)); + sargs_orig = sargs = calloc(1, sizeof(struct btrfs_ioctl_space_args)); if (!sargs) { fprintf(stderr, "ERROR: not enough memory\n"); return NULL; @@ -476,15 +476,15 @@ int load_device_info(int fd, struct device_info **device_info_ptr, return -1; } - info = malloc(sizeof(struct device_info) * fi_args.num_devices); + info = calloc(fi_args.num_devices, sizeof(struct device_info)); if (!info) { fprintf(stderr, "ERROR: not enough memory\n"); return -1; } for (i = 0, ndevs = 0 ; i <= fi_args.max_id ; i++) { - BUG_ON(ndevs >= fi_args.num_devices); + memset(&dev_info, 0, sizeof(dev_info)); ret = get_device_info(fd, i, &dev_info); if (ret == -ENODEV)