Check return value from pathinfo()
authorHannes Reinecke <hare@suse.de>
Tue, 16 Jul 2013 07:13:04 +0000 (09:13 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 16 Jul 2013 19:50:42 +0000 (21:50 +0200)
pathinfo() has a return value, which should be checked to catch
any abnormal behaviour.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/configure.c
libmultipath/discovery.c
multipath/main.c

index e5048eb..1dfcfc3 100644 (file)
@@ -800,8 +800,14 @@ extern int reload_map(struct vectors *vecs, struct multipath *mpp, int refresh)
 
        update_mpp_paths(mpp, vecs->pathvec);
        if (refresh) {
-               vector_foreach_slot (mpp->paths, pp, i)
-                       pathinfo(pp, conf->hwtable, DI_PRIO);
+               vector_foreach_slot (mpp->paths, pp, i) {
+                       r = pathinfo(pp, conf->hwtable, DI_PRIO);
+                       if (r) {
+                               condlog(2, "%s: failed to refresh pathinfo",
+                                       mpp->alias);
+                               return 1;
+                       }
+               }
        }
        if (setup_map(mpp, params, PARAMS_SIZE)) {
                condlog(0, "%s: failed to setup map", mpp->alias);
index fcb8e4f..9137ed2 100644 (file)
@@ -125,8 +125,10 @@ path_discovery (vector pathvec, struct config * conf, int flag)
                        continue;
                }
                devtype = udev_device_get_devtype(udevice);
-               if(devtype && !strncmp(devtype, "disk", 4))
-                       r += path_discover(pathvec, conf, udevice, flag);
+               if(devtype && !strncmp(devtype, "disk", 4)) {
+                       r += path_discover(pathvec, conf,
+                                                  udevice, flag);
+               }
                udev_device_unref(udevice);
        }
        udev_enumerate_unref(udev_iter);
index 4a8b966..842a787 100644 (file)
@@ -152,16 +152,21 @@ update_paths (struct multipath * mpp)
                                        continue;
                                }
                                pp->mpp = mpp;
-                               pathinfo(pp, conf->hwtable, DI_ALL);
+                               if (pathinfo(pp, conf->hwtable, DI_ALL))
+                                       pp->state = PATH_UNCHECKED;
                                continue;
                        }
                        pp->mpp = mpp;
                        if (pp->state == PATH_UNCHECKED ||
-                           pp->state == PATH_WILD)
-                               pathinfo(pp, conf->hwtable, DI_CHECKER);
+                           pp->state == PATH_WILD) {
+                               if (pathinfo(pp, conf->hwtable, DI_CHECKER))
+                                       pp->state = PATH_UNCHECKED;
+                       }
 
-                       if (pp->priority == PRIO_UNDEF)
-                               pathinfo(pp, conf->hwtable, DI_PRIO);
+                       if (pp->priority == PRIO_UNDEF) {
+                               if (pathinfo(pp, conf->hwtable, DI_PRIO))
+                                       pp->priority = PRIO_UNDEF;
+                       }
                }
        }
        return 0;