From patchwork Mon Jun 30 05:13:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 4445661 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@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 A61BFBEEAA for ; Mon, 30 Jun 2014 05:18:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E11AE202F8 for ; Mon, 30 Jun 2014 05:18:36 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mail.kernel.org (Postfix) with ESMTP id 094EF20221 for ; Mon, 30 Jun 2014 05:18:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5U5F9lj005346; Mon, 30 Jun 2014 01:15:10 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s5U5E7gc026016 for ; Mon, 30 Jun 2014 01:14:07 -0400 Received: from dhcp80-209.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5U5E7Ys028146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 30 Jun 2014 01:14:07 -0400 Received: from dhcp80-209.msp.redhat.com (localhost [127.0.0.1]) by dhcp80-209.msp.redhat.com (8.14.7/8.14.7) with ESMTP id s5U5E6ih005108; Mon, 30 Jun 2014 00:14:06 -0500 Received: (from bmarzins@localhost) by dhcp80-209.msp.redhat.com (8.14.7/8.14.7/Submit) id s5U5E6dS005107; Mon, 30 Jun 2014 00:14:06 -0500 From: Benjamin Marzinski To: device-mapper development Date: Mon, 30 Jun 2014 00:13:52 -0500 Message-Id: <1404105243-5071-2-git-send-email-bmarzins@redhat.com> In-Reply-To: <1404105243-5071-1-git-send-email-bmarzins@redhat.com> References: <1404105243-5071-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 01/12] Fix memory issues in path reordering failure code paths X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 There were some possible NULL pointer dereferences and multiple frees in the failure code paths of the path reordering code. This patch cleans them up. Signed-off-by: Benjamin Marzinski --- libmultipath/configure.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 3ed6b55..6ad7a80 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -160,8 +160,16 @@ int order_paths_in_pg_by_alt_adapters(struct pathgroup *pgp, vector adapters, while (total_paths > 0) { agp = VECTOR_SLOT(adapters, next_adapter_index); + if (!agp) { + condlog(0, "can't get adapter group %d", next_adapter_index); + return 1; + } hgp = VECTOR_SLOT(agp->host_groups, agp->next_host_index); + if (!hgp) { + condlog(0, "can't get host group %d of adapter group %d", next_adapter_index, agp->next_host_index); + return 1; + } if (!hgp->num_paths) { agp->next_host_index++; @@ -223,8 +231,8 @@ int rr_optimize_path_order(struct pathgroup *pgp) /* group paths in path group by host adapters */ if (group_by_host_adapter(pgp, adapters)) { + /* already freed adapters */ condlog(3, "Failed to group paths by adapters"); - free_adaptergroup(adapters); return 0; }