From patchwork Thu Dec 18 06:09:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Satoru Takeuchi X-Patchwork-Id: 5510551 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 D8A82BEEA8 for ; Thu, 18 Dec 2014 06:10:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 24DD0209DE for ; Thu, 18 Dec 2014 06:10:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBDC620935 for ; Thu, 18 Dec 2014 06:10:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbaLRGKX (ORCPT ); Thu, 18 Dec 2014 01:10:23 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:60148 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbaLRGKV (ORCPT ); Thu, 18 Dec 2014 01:10:21 -0500 Received: from kw-mxoi2.gw.nic.fujitsu.com (unknown [10.0.237.143]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 1506B3EE0C1 for ; Thu, 18 Dec 2014 15:10:20 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by kw-mxoi2.gw.nic.fujitsu.com (Postfix) with ESMTP id 28EACAC0809 for ; Thu, 18 Dec 2014 15:10:19 +0900 (JST) Received: from g01jpfmpwkw01.exch.g01.fujitsu.local (g01jpfmpwkw01.exch.g01.fujitsu.local [10.0.193.38]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id CC338E08005 for ; Thu, 18 Dec 2014 15:10:18 +0900 (JST) Received: from g01jpexchkw35.g01.fujitsu.local (unknown [10.0.193.4]) by g01jpfmpwkw01.exch.g01.fujitsu.local (Postfix) with ESMTP id 1B75D692304; Thu, 18 Dec 2014 15:10:18 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v2.0.1 X-SHieldMailCheckerPolicyVersion: FJ-ISEC-20120718-4 Message-ID: <54926FB4.6050604@jp.fujitsu.com> Date: Thu, 18 Dec 2014 15:09:56 +0900 From: Satoru Takeuchi User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: "linux-btrfs@vger.kernel.org" CC: naota Subject: [PATCH 1/2] Fix wrong memory free on check_is_root X-SecurityPolicyCheck-GC: OK by FENCE-Mail 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=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 From: Satoru Takeuchi Date: Thu, 18 Dec 2014 14:35:22 +0900 @tmp is freed even if its allocation fails. Signed-off-by: Satoru Takeuchi --- cmds-property.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmds-property.c b/cmds-property.c index a764293..a4bc127 100644 --- a/cmds-property.c +++ b/cmds-property.c @@ -140,31 +140,32 @@ static int check_is_root(const char *object) if (ret < 0) { fprintf(stderr, "ERROR: get_fsid for %s failed. %s\n", object, strerror(-ret)); - goto out; + goto free_tmp_out; } ret = get_fsid(tmp, fsid2, 1); if (ret == -ENOTTY) { ret = 0; - goto out; + goto free_tmp_out; } else if (ret == -ENOTDIR) { ret = 1; - goto out; + goto free_tmp_out; } else if (ret < 0) { fprintf(stderr, "ERROR: get_fsid for %s failed. %s\n", tmp, strerror(-ret)); - goto out; + goto free_tmp_out; } if (memcmp(fsid, fsid2, BTRFS_FSID_SIZE)) { ret = 0; - goto out; + goto free_tmp_out; } ret = 1; -out: +free_tmp_out: free(tmp); +out: return ret; }