From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B9DA4A0548; Mon, 26 Apr 2021 16:55:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8494B41110; Mon, 26 Apr 2021 16:55:05 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 15B6441104 for ; Mon, 26 Apr 2021 16:55:02 +0200 (CEST) IronPort-SDR: lfvi20yYWim6FKX/XK96afo4cqAJvBPa2JSy5KYdMdhHUSnYBFdmX57lLDknwFLdWweYNwi8fk ooRoMhbWmgjg== X-IronPort-AV: E=McAfee;i="6200,9189,9966"; a="281676832" X-IronPort-AV: E=Sophos;i="5.82,252,1613462400"; d="scan'208";a="281676832" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2021 07:55:01 -0700 IronPort-SDR: BNh3voBoNGomsDdt6aiyrmuqV5kmj+Hy0FUF3HRkaIWQsYElvBSrlwYheB/a6r8saWGqGeCjFT eqTktNMHrH9g== X-IronPort-AV: E=Sophos;i="5.82,252,1613462400"; d="scan'208";a="429420667" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.241.96]) ([10.213.241.96]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2021 07:55:01 -0700 To: "Min Hu (Connor)" , dev@dpdk.org References: <1619075569-33619-1-git-send-email-humin29@huawei.com> From: Ferruh Yigit X-User: ferruhy Message-ID: Date: Mon, 26 Apr 2021 15:54:57 +0100 MIME-Version: 1.0 In-Reply-To: <1619075569-33619-1-git-send-email-humin29@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net/bonding: fix socket id check 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 Sender: "dev" On 4/22/2021 8:12 AM, Min Hu (Connor) wrote: > From: Chengchang Tang > > The socket ID entered by user is cast to an unsigned integer. However, > the value may be an illegal negative value, which may cause some > problems. In this case, an error should be returned. > +1 to fix > In addition, the socket ID may be an invalid positive number, which is > also processed in this patch. > > Fixes: 2efb58cbab6e ("bond: new link bonding library") > Cc: stable@dpdk.org > > Signed-off-by: Chengchang Tang > Signed-off-by: Min Hu (Connor) > --- > drivers/net/bonding/rte_eth_bond_args.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c > index 8c5f90d..bcc0fe3 100644 > --- a/drivers/net/bonding/rte_eth_bond_args.c > +++ b/drivers/net/bonding/rte_eth_bond_args.c > @@ -207,12 +207,12 @@ bond_ethdev_parse_socket_id_kvarg(const char *key __rte_unused, > return -1; > > errno = 0; > - socket_id = (uint8_t)strtol(value, &endptr, 10); > + socket_id = strtol(value, &endptr, 10); 'strtol()' returns 'long int', but implicitly casting it to 'int'. My concern is if this cause a static analysis tool warning. What do you think to have 'socket_id' type as 'long int'? > if (*endptr != 0 || errno != 0) > return -1; > > /* validate socket id value */ > - if (socket_id >= 0) { > + if (socket_id >= 0 && socket_id < RTE_MAX_NUMA_NODES) {> *(uint8_t *)extra_args = (uint8_t)socket_id; Here there is an assumption that RTE_MAX_NUMA_NODES will be less than 'UCHAR_MAX', perhaps it can be good to add a check to verify this assumption. > return 0; > } >