From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 862EAA0577; Tue, 7 Apr 2020 18:25:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 63D061BEE0; Tue, 7 Apr 2020 18:25:40 +0200 (CEST) Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by dpdk.org (Postfix) with ESMTP id 4C4042BE2 for ; Tue, 7 Apr 2020 18:25:39 +0200 (CEST) Received: by mail-lf1-f65.google.com with SMTP id 131so2834126lfh.11 for ; Tue, 07 Apr 2020 09:25:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=rKYQwqTTryi3D7VIzI3gTawJv5o7fIXLpEtopY37mo0=; b=Bp2kheQnZR9bjZTr6EoX0SmVsJmYGJTEO+hbvUl5ANBb0RSJRf9UuIMiLIHrv7CG2E o9qEguOYO35WeS1s5FycKXM6+sWQSWv+xyg+S/H2CJX2w/eLm2VFXn+D5Gk2fspz0sl5 rjXYlr1lMNb3N+pUP//EdmPoeB5hHxB8l9nLLtn64ksnWhRKeQvOTrhOxJ9+Io1l2PFd rLzBN6Kq/ZqWaTaNAzd7XYCE5MDxRVra/5aGGQVFCW3uOd6j81BO6zabe9NbOVvecfg1 gDPc1VEMNcg4s1BBARXyT9ZkzLMnH2EbUcgRaJW/dgkGiZLjQdPjVUKAM6QVR6MdUG24 M6pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rKYQwqTTryi3D7VIzI3gTawJv5o7fIXLpEtopY37mo0=; b=Eq5BIGJcd+wQqs0LE9qvoBEJAAEHQkKDhEE5+I7Z91bSBpgZWvYnY32TkrhkuuYaIE uPIzee/CidiDJP4276q9wXLUt4W1WOUxCBnxFBLMhS+57J8mW/eOt6BkUs6I0xNWVIO9 ay6pdbShBWzeOewMBuwy7IJT3WTXqbJQh6TX6haPBfxS5hs0DXK9vt6H1FbGUu78C0Aa X33HVf7rmY/FdwpPRZDd97P1OxIBWPGI1Us7VBpJkA9EXt0rFQ89bk4XV3EsYR+JjQnE eWnX4ZF12Jk1jDv+i2Qbe4H+W0CXmOl8OkLDqSxa0VmCCAn5WYWt8IHB4oDopmDFSE+b r6oQ== X-Gm-Message-State: AGi0PubtuHizHaJGMA8R1VtTzeJbYd7EI8AtDnM3P/yfeCdAMht70lEA hQ56DEZbSSLCW0QTB5KwCd04og== X-Google-Smtp-Source: APiQypJo+oS/svYzdy3ICTI5SmZBXq8GDGxpwWsIqC+2ZolbdARoMEpUMrAQsdw8onoYCAzXdHgeMg== X-Received: by 2002:ac2:4a76:: with SMTP id q22mr1955554lfp.157.1586276738921; Tue, 07 Apr 2020 09:25:38 -0700 (PDT) Received: from localhost.localdomain ([182.191.83.208]) by smtp.gmail.com with ESMTPSA id t8sm14345687lfe.31.2020.04.07.09.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 09:25:38 -0700 (PDT) From: Talal Irfan To: adrien.mazarguil@6wind.com, thomas@monjalon.net Cc: dev@dpdk.org, Talal Irfan , stable@dpdk.org Date: Tue, 7 Apr 2020 21:25:23 +0500 Message-Id: <20200407162523.6899-1-talal.irfan@emumba.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH 17.11] lib/librte_ether/rte_ethdev.c: Check device count X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Bugzilla ID: 6 Cc: dev@dpdk.org Cc: Thomas Monjalon Cc: Adrien Mazarguil Cc: stable@dpdk.org Reported-by: Wang Zhike Suggested-by: Vipin Varghese Signed-off-by: Talal Irfan --- lib/librte_ether/rte_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 318af2869..ac19baf0c 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -376,6 +376,12 @@ rte_eth_dev_attach(const char *devargs, uint16_t *port_id) goto err; } + if (current <= 0) { + RTE_LOG(ERR, EAL, "No port found for device (%s)\n", name); + ret = -EINVAL; + goto err; + } + /* parse devargs, then retrieve device name and args */ if (rte_eal_parse_devargs_str(devargs, &name, &args)) goto err; -- 2.17.1