From patchwork Sun Mar 8 03:31:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 5961071 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6E0FBBF440 for ; Sun, 8 Mar 2015 04:39:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77B172025B for ; Sun, 8 Mar 2015 04:39:32 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDEF420251 for ; Sun, 8 Mar 2015 04:39:30 +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 t284ajZx007000; Sat, 7 Mar 2015 23:36:45 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t284Zj7B009457 for ; Sat, 7 Mar 2015 23:35:45 -0500 Received: from redhat.com (ask-08.lab.msp.redhat.com [10.15.85.8]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t284ZiP1006010; Sat, 7 Mar 2015 23:35:44 -0500 Received: by redhat.com (sSMTP sendmail emulation); Sat, 07 Mar 2015 21:32:11 -0600 From: "Benjamin Marzinski" To: device-mapper development Date: Sat, 7 Mar 2015 21:31:45 -0600 Message-Id: <1425785506-20419-15-git-send-email-bmarzins@redhat.com> In-Reply-To: <1425785506-20419-1-git-send-email-bmarzins@redhat.com> References: <1425785506-20419-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 14/15] Fix doublee free of alias after map add failure 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 In ev_add_map(), if add_map_without_path() fails, the alias will have been freed by free_multipath(), so you can't access it anymore. Also, if the multipath device already exists, but you fail to register it, there's no point in trying to create the device. It will fail. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index aac8a19..62339ae 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -314,10 +314,15 @@ ev_add_map (char * dev, char * alias, struct vectors * vecs) /* * now we can register the map */ - if (map_present && (mpp = add_map_without_path(vecs, alias))) { - sync_map_state(mpp); - condlog(2, "%s: devmap %s registered", alias, dev); - return 0; + if (map_present) { + if ((mpp = add_map_without_path(vecs, alias))) { + sync_map_state(mpp); + condlog(2, "%s: devmap %s registered", alias, dev); + return 0; + } else { + condlog(2, "%s: uev_add_map failed", dev); + return 1; + } } r = get_refwwid(dev, DEV_DEVMAP, vecs->pathvec, &refwwid);