rdma: Protect dev_map_lookup from wrong input

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: 40df8263a0 ("rdma: Add dev object")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
Leon Romanovsky 2017-12-27 09:57:51 +02:00 committed by David Ahern
parent 0fc8c30b4e
commit 99da90326e
1 changed files with 3 additions and 0 deletions

View 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, '/');