Most crashes are due to vector_foreach_slot not checking for NULL
argument. Do that now, and add some more checks for not accessing
a NULL pointer indirection.
Signed-off-by: Hannes Reinecke <hare@suse.de>
struct pathgroup * cpgp;
int r = 0;
+ if (!mpp)
+ return 0;
+
vector_foreach_slot (mpp->pg, pgp, i) {
compute_pgid(pgp);
int i;
struct multipath * mpp;
- if (!vecs->mpvec)
+ if (!vecs)
return;
vector_foreach_slot (vecs->mpvec, mpp, i) {
int count = 0;
int i, j;
- if (!mpp->paths)
+ if (!mpp)
return 0;
vector_foreach_slot (mpp->paths, pp, i) {
if (setup_multipath(vecs, mpp))
return 1; /* mpp freed in setup_multipath */
- if (!mpp->pg)
- return 0; /* Can happen when all paths are down */
-
/*
* compare checkers states with DM states
*/
#define VECTOR_LAST_SLOT(V) ((V)->slot[((V)->allocated - 1)])
#define vector_foreach_slot(v,p,i) \
- for (i = 0; i < (v)->allocated && ((p) = (v)->slot[i]); i++)
+ for (i = 0; (v) && i < (v)->allocated && ((p) = (v)->slot[i]); i++)
#define vector_foreach_slot_after(v,p,i) \
- for (; i < (v)->allocated && ((p) = (v)->slot[i]); i++)
+ for (; (v) && i < (v)->allocated && ((p) = (v)->slot[i]); i++)
/* Prototypes */
extern vector vector_alloc(void);