From patchwork Mon Jul 10 17:07:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 129423 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DDF6A42E3C; Mon, 10 Jul 2023 19:08:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 66A9C40EE4; Mon, 10 Jul 2023 19:08:08 +0200 (CEST) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by mails.dpdk.org (Postfix) with ESMTP id E5B5340EE4 for ; Mon, 10 Jul 2023 19:08:05 +0200 (CEST) Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6686708c986so4182013b3a.0 for ; Mon, 10 Jul 2023 10:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1689008885; x=1691600885; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KbFQUlYs6HQbdGpJ+pYHgzZS0d5/E2CJRCb/AY/vnpU=; b=y/c65iVFfeOXu3hBRPlHJ4WPXaa59Qvzmz3r4CLlkqS8OJHiQHjgOeiC2fbzlc3qJp i1ZvEgo63sIGHDCLbaon40vZTSgk7cX3OlKUpTEx0APhjj7Fv7wlpMBe2G4ErSzPOGfa xzV+W3hm+fSsYzX2VPwcNX19VAdPzRCEjCYiGPfY0yc358bzdVzRXeDUQsRPgU/VE5BV r4upjEklHy68sYDM87taWzK0kURAoTqqIXVx4d9AbFQ/L3LaLlWODPK2EqByE7gZYRNx aKou9zoeo9d7KWGR5coUEgKGSshJDGunWhmmWpaEWPwFXeBrecyXS6ixVm4wdnTqS7SK lVKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689008885; x=1691600885; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KbFQUlYs6HQbdGpJ+pYHgzZS0d5/E2CJRCb/AY/vnpU=; b=DNLSpaGFSngCKcvqlph0VFYFWXlIvceX5m2Ywi10Q2yFQ5TDKOaE1KcR/FO6/kcW4T fqlmNVDE7lIqQPuMn2MHRHWHfNW9hAqfHj8bCQCdXEiVx3RNn6JbqlA6WDGIWldd18zg yNo7/9JONC7EXnLhYE9RlVDHMrS8o6MSBu0JRFf+KaHfw6VaKZ/3pBbREyGPrUztF3+N 4N2v0hrnyGV467MqUm3vHZ5UnZS78D/gd/V4g6AFOphKceFx9umPsBbW0C9FYy5OlJrd C2Zqz8GRED9dJfX75qByOhHcUT7/z6Py2f5mkqQGuaRIir9HW9YYQfZgeDAvhKMslqT+ zH6g== X-Gm-Message-State: ABy/qLYg/SY6jMTqt7xggaIWTSxBWtLr+8aWgPSqGmT59Yiw004JH+GF 8PK2Gq+M5oDdlZ5z8VfGZofM0LvnZ7oQUWPDUOsgEw== X-Google-Smtp-Source: APBJJlHeuRilX+IpRTQ5P5RHPOrEVPtDcPkOg23ZhDphegUgbt8A1uW+n/lnraCQdHZJG6ACthLCFw== X-Received: by 2002:a05:6a00:22cc:b0:666:d78c:33ab with SMTP id f12-20020a056a0022cc00b00666d78c33abmr17844905pfj.21.1689008884848; Mon, 10 Jul 2023 10:08:04 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id q17-20020a62e111000000b00682ed27f99dsm51799pfh.46.2023.07.10.10.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 10:08:04 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Sinan Kaya , Stephen Hemminger , =?utf-8?q?Morten_Br=C3=B8ru?= =?utf-8?q?p?= , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Subject: [PATCH v4 2/5] ethdev: check return result of rte_eth_dev_info_get Date: Mon, 10 Jul 2023 10:07:57 -0700 Message-Id: <20230710170800.12478-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230710170800.12478-1-stephen@networkplumber.org> References: <20230120044140.95975-1-okaya@kernel.org> <20230710170800.12478-1-stephen@networkplumber.org> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Sinan Kaya rte_class_eth: eth_mac_cmp: The status of this call to rte_eth_dev_info_get is not checked, potentially leaving dev_info uninitialized. Signed-off-by: Sinan Kaya Signed-off-by: Stephen Hemminger Reviewed-by: Morten Brørup Reviewed-by: Andrew Rybchenko --- lib/ethdev/rte_class_eth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c index b61dae849dce..05c100efbba3 100644 --- a/lib/ethdev/rte_class_eth.c +++ b/lib/ethdev/rte_class_eth.c @@ -50,8 +50,10 @@ eth_mac_cmp(const char *key __rte_unused, if (rte_ether_unformat_addr(value, &mac) < 0) return -1; /* invalid devargs value */ + if (rte_eth_dev_info_get(data->port_id, &dev_info) < 0) + return -1; + /* Return 0 if devargs MAC is matching one of the device MACs. */ - rte_eth_dev_info_get(data->port_id, &dev_info); for (index = 0; index < dev_info.max_mac_addrs; index++) if (rte_is_same_ether_addr(&mac, &data->mac_addrs[index])) return 0;