]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
rdma: Protect dev_map_lookup from wrong input
authorLeon Romanovsky <leonro@mellanox.com>
Wed, 27 Dec 2017 07:57:51 +0000 (09:57 +0200)
committerDavid Ahern <dsahern@gmail.com>
Wed, 27 Dec 2017 15:47:35 +0000 (07:47 -0800)
Despite the fact that all callers to dev_map_lookup are ensuring that
there is always device name prior to call to that function, it is better
and safer to check that in the dev_map_lookup itself.

Fixes: 40df8263a0f0 ("rdma: Add dev object")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
rdma/utils.c

index 6ce1fd70e058fa96d206f1465aa43b2871773891..bb29fa1a2386eb678244fa9b232955cc801da60c 100644 (file)
@@ -253,6 +253,9 @@ struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index)
        char *dev_name;
        char *slash;
 
+       if (rd_no_arg(rd))
+               return NULL;
+
        dev_name = strdup(rd_argv(rd));
        if (allow_port_index) {
                slash = strrchr(dev_name, '/');