diff mbox

check info.exists to get valid value

Message ID 1403683708-14220-1-git-send-email-vaughan.cao@oracle.com (mailing list archive)
State Accepted, archived
Delegated to: christophe varoqui
Headers show

Commit Message

vaughan June 25, 2014, 8:08 a.m. UTC
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 <vaughan.cao@oracle.com>
---
 libmultipath/devmapper.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Christophe Varoqui July 1, 2014, 6:32 p.m. UTC | #1
Applied.
Thanks.


On Wed, Jun 25, 2014 at 10:08 AM, Vaughan Cao <vaughan.cao@oracle.com>
wrote:

> 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 <vaughan.cao@oracle.com>
> ---
>  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;
>
> --
> 1.9.0
>
>
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

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;