Blob Blame History Raw
From 05fd4c2c9d99d757b539185c1740a5943f48188f Mon Sep 17 00:00:00 2001
From: Leon Romanovsky <leonro@mellanox.com>
Date: Wed, 27 Dec 2017 09:57:51 +0200
Subject: [PATCH] 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: 40df8263a0f0 ("rdma: Add dev object")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
(cherry picked from commit 99da90326e6af8e17400a01cf48bb60606dd22a6)
Signed-off-by: Phil Sutter <psutter@redhat.com>
---
 rdma/utils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/rdma/utils.c b/rdma/utils.c
index 6ce1fd70e058f..bb29fa1a2386e 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -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, '/');
-- 
2.15.1