From patchwork Wed Jun 25 08:08:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vaughan X-Patchwork-Id: 4426531 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 523B0BEEAA for ; Thu, 26 Jun 2014 07:34:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D6E1203AA for ; Thu, 26 Jun 2014 07:34:51 +0000 (UTC) Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mail.kernel.org (Postfix) with ESMTP id B7D97203A0 for ; Thu, 26 Jun 2014 07:34:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s5Q7SUU5010862; Thu, 26 Jun 2014 03:28:31 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s5P87xQW021794 for ; Wed, 25 Jun 2014 04:08:00 -0400 Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.16]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5P87xYP006819 for ; Wed, 25 Jun 2014 04:07:59 -0400 Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5P87vAr030018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 25 Jun 2014 04:07:57 -0400 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s5P87pvY024946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Jun 2014 08:07:54 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s5P87naI019703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 25 Jun 2014 08:07:50 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s5P87nr9019062; Wed, 25 Jun 2014 08:07:49 GMT Received: from vacaowork.cn.oracle.com (/10.182.37.211) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Jun 2014 01:07:48 -0700 From: Vaughan Cao To: christophe.varoqui@opensvc.com Date: Wed, 25 Jun 2014 16:08:28 +0800 Message-Id: <1403683708-14220-1-git-send-email-vaughan.cao@oracle.com> X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-RedHat-Spam-Score: -104.31 (BAYES_00, DCC_REPUT_13_19, RCVD_IN_DNSWL_MED, SPF_PASS, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY, USER_IN_WHITELIST) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.16 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 26 Jun 2014 03:28:30 -0400 Cc: dm-devel@redhat.com, vaughan.cao@oracle.com Subject: [dm-devel] [PATCH] check info.exists to get valid value 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=-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 dm_task_get_info will still return 1 if device doesn't exist. Check info.exists to ensure major and minor values are valid. There is no reason to assign info.open_count to @r here. Signed-off-by: Vaughan Cao --- libmultipath/devmapper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 30e9351..3d4c111 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -567,10 +567,9 @@ dm_dev_t (const char * mapname, char * dev_t, int len) if (!dm_task_run(dmt)) goto out; - if (!dm_task_get_info(dmt, &info)) + if (!dm_task_get_info(dmt, &info) || !info.exists) goto out; - r = info.open_count; if (snprintf(dev_t, len, "%i:%i", info.major, info.minor) > len) goto out;