From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leon Romanovsky Subject: [PATCH iproute2-next 02/10] rdma: Protect dev_map_lookup from wrong input Date: Wed, 27 Dec 2017 09:57:51 +0200 Message-ID: <20171227075759.15289-3-leon@kernel.org> References: <20171227075759.15289-1-leon@kernel.org> Cc: Leon Romanovsky , netdev , Stephen Hemminger To: David Ahern Return-path: Received: from mail.kernel.org ([198.145.29.99]:46512 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751002AbdL0H6K (ORCPT ); Wed, 27 Dec 2017 02:58:10 -0500 In-Reply-To: <20171227075759.15289-1-leon@kernel.org> Sender: netdev-owner@vger.kernel.org List-ID: From: Leon Romanovsky 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 --- rdma/utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rdma/utils.c b/rdma/utils.c index 6ce1fd70..bb29fa1a 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