From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by dpdk.org (Postfix) with ESMTP id 05C062E7B for ; Fri, 7 Aug 2015 11:21:47 +0200 (CEST) Received: by pabxd6 with SMTP id xd6so66074734pab.2 for ; Fri, 07 Aug 2015 02:21:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0nl1DQDKPeM3p8iJvb6M7RjuLfnIhefTsnbOT7kE3y4=; b=RfHohQr/qXezI6k6ar4V2ema4MEcU0d4SgIAxlqaaMqsEweIF7DHT9xbMmaYT+D4pV 6Iu8iSxhQMxk7946HLdM17EkZYQjdmgl620kcxpdJdgOffWRnMb+Wz7b7zV1CNSyLm3Y qzTHR4TnYHamrwwfJjDrprrptDlWPcmVbB1GKEjMCUTRZNzo08u2/MUngt7tYchrUlJ0 crplppv7LWId6tZHF3L32vmwojTs40IqwyB1GXz3eqgtOR+dH4+VIhpXm6ORX4dHnQNx OL5E2Zcm3byaibtb1O7Vh1Yjay8xquvU8zluB3MX4R9218euQTN72tnBGPJqaNr/2K/F Aq+A== X-Gm-Message-State: ALoCoQk3V+GKY5aeESOIvnylmD5wKdTcKr8HXVod5jqRnVGW9LcCB0/HZhTvBl2J4A32ginK0ohT X-Received: by 10.66.236.167 with SMTP id uv7mr12403363pac.134.1438939306140; Fri, 07 Aug 2015 02:21:46 -0700 (PDT) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id nu6sm9303917pbb.64.2015.08.07.02.21.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Aug 2015 02:21:45 -0700 (PDT) From: Tetsuya Mukawa To: dev@dpdk.org Date: Fri, 7 Aug 2015 18:21:26 +0900 Message-Id: <1438939286-19641-1-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 2.1.4 Subject: [dpdk-dev] [PATCH] ethdev: Fix illegal access of rte_eth_dev_is_detachable() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Aug 2015 09:21:47 -0000 To obtain detachable flag, pci_drv is accessed in rte_eth_dev_is_detachable(). But pci_drv is only valid if port is enabled. Not to cause illegal access, add rte_eth_dev_is_valid_port() before accessing. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 5fe1906..6b2400c 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -505,7 +505,7 @@ rte_eth_dev_is_detachable(uint8_t port_id) { uint32_t drv_flags; - if (port_id >= RTE_MAX_ETHPORTS) { + if (!rte_eth_dev_is_valid_port(port_id)) { PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); return -EINVAL; } -- 2.1.4