On 1/4/18 12:01 AM, Leon Romanovsky wrote: > diff --git a/rdma/utils.c b/rdma/utils.c > index af2b374d..446c23da 100644 > --- a/rdma/utils.c > +++ b/rdma/utils.c > @@ -114,6 +114,225 @@ static void dev_map_cleanup(struct rd *rd) > } > } > > +static int add_filter(struct rd *rd, char *key, char *value, > + const char * const valid_filters[]) > +{ > + char cset[] = "1234567890,-"; > + struct filter_entry *fe; > + bool key_found = false; > + int idx = 0; > + int ret; > + > + fe = calloc(1, sizeof(*fe)); > + if (!fe) > + return -ENOMEM; > + > + while (valid_filters[idx]) { > + if (!strcmpx(key, valid_filters[idx])) { > + key_found = true; > + break; > + } > + idx++; > + } > + if (!key_found) { > + pr_err("Unsupported filter option: %s\n", key); > + ret = -EINVAL; > + goto err; > + } > + > + /* > + * Check the filter validity, not optimal, but works > + * > + * Actually, there are three types of filters > + * numeric - for example PID or QPN > + * string - for example states, currently only "display" > + * is from this type > + * link - user requested to filter on specific link > + * e.g. mlx5_1/1, mlx5_1/-, mlx5_1 ... > + */ > + if (strcmpx(key, "link") && strcmpx(key, "display") && > + strspn(value, cset) != strlen(value)) { > + pr_err("%s filter accepts \"%s\" characters only\n", key, cset); > + ret = -EINVAL; > + goto err; > + } > + > + fe->key = strdup(key); > + fe->value = strdup(value); > + Missed this the other day. 2 more strdup's that should be checked. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html