From patchwork Tue Jul 20 08:10:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 112979 Received: from mx01.colomx.prod.int.phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6K8CxoJ023994 for ; Tue, 20 Jul 2010 08:14:04 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx01.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6K8AWIJ029753; Tue, 20 Jul 2010 04:10:35 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6K8AU3P019713 for ; Tue, 20 Jul 2010 04:10:30 -0400 Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.6]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6K8APHE030594 for ; Tue, 20 Jul 2010 04:10:25 -0400 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6K8AFPd002064 for ; Tue, 20 Jul 2010 04:10:15 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 991485FC9F; Tue, 20 Jul 2010 10:10:14 +0200 (CEST) Date: Tue, 20 Jul 2010 10:10:14 +0200 To: Christophe Varoqui User-Agent: Heirloom mailx 12.2 01/07/07 MIME-Version: 1.0 Message-Id: <20100720081014.5885D29D22@ochil.suse.de> From: hare@suse.de (Hannes Reinecke) X-RedHat-Spam-Score: -2.31 (RCVD_IN_DNSWL_MED,T_RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.6 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH] libmultipath: always allocate space for alias 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 20 Jul 2010 08:14:04 +0000 (UTC) diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index ee4109e..3074ce1 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -239,7 +239,7 @@ extern int select_alias (struct multipath * mp) { if (mp->mpe && mp->mpe->alias) - mp->alias = mp->mpe->alias; + mp->alias = STRDUP(mp->mpe->alias); else { mp->alias = NULL; if (conf->user_friendly_names) { @@ -257,7 +257,7 @@ select_alias (struct multipath * mp) } } if (mp->alias == NULL) - mp->alias = mp->wwid; + mp->alias = STRDUP(mp->wwid); } return 0; @@ -472,7 +472,7 @@ select_pg_timeout(struct multipath *mp) return 0; } mp->pg_timeout = PGTIMEOUT_UNDEF; - condlog(3, "pg_timeout = NONE (internal default)"); + condlog(3, "%s: pg_timeout = NONE (internal default)", mp->alias); return 0; } diff --git a/libmultipath/structs.c b/libmultipath/structs.c index a4b86d2..82df680 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -163,9 +163,7 @@ free_multipath (struct multipath * mpp, int free_paths) free_multipath_attributes(mpp); - if (mpp->alias && - (!mpp->mpe || (mpp->mpe && mpp->alias != mpp->mpe->alias)) && - (mpp->wwid && mpp->alias != mpp->wwid)) { + if (mpp->alias) { FREE(mpp->alias); mpp->alias = NULL; } diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 699efa1..51c41e8 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -335,8 +335,13 @@ retry: condlog(3, "%s: discover", mpp->alias); if (update_multipath_strings(mpp, vecs->pathvec)) { - char new_alias[WWID_SIZE]; + char *new_alias; + new_alias = MALLOC(WWID_SIZE); + if (!new_alias) { + condlog(0, "%s: failed to allocate alias", mpp->alias); + goto out; + } /* * detect an external rename of the multipath device */ @@ -344,7 +349,8 @@ retry: condlog(3, "%s multipath mapped device name has " "changed from %s to %s", mpp->wwid, mpp->alias, new_alias); - strcpy(mpp->alias, new_alias); + FREE(mpp->alias); + mpp->alias = new_alias; if (mpp->waiter) strncpy(((struct event_thread *)mpp->waiter)->mapname,