From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id BCDD22B8C for ; Mon, 12 Nov 2018 10:29:26 +0100 (CET) Received: by mail-wr1-f68.google.com with SMTP id o15-v6so8457630wrv.4 for ; Mon, 12 Nov 2018 01:29:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=zrVQV39hPtGqXIG3CtP8zEuppIn8iPevaD7GQcx8SAE=; b=j+kiegObnXRRc/uPbTKbWs+SBx8ZTj3TfOsZF4ou7tyL0JQQfnXo4wgIbYKk2x9GjS YT+AzKlBvGv8tj6RhdJTC1GhvpvDkus+hI1YgQB3ZoQBxKWW88c4ioW92Ynr+VXJWAOw bp66DZiESavHmFiz5e3v8mgJGTbchviNPMPX7BVF3YQfTUnLCpqvgGB8owKAqusKDz3i +HHzmaKe9P18myJsqGHjPEu7XSnZtRTAdIicms2UsiSiHN+8mGyKIZ/WSkXH8bUBOF8f 830aqwXFazuLjYu2AhByEM7pHevnypW3dtlan6hCLTKD9VUUUlRCXqTubC/EmMRZBIcK V5UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=zrVQV39hPtGqXIG3CtP8zEuppIn8iPevaD7GQcx8SAE=; b=djs7btEatZxC8Cy+Ch4pKA44WyR/HXDQp70VjN1/0g/5HeM2ctpJvNjpogVQziD4CD vmoyB5nfUkW6259qA0uECOBNlRraM4dQ9TbRmpxDkycyHj4mlE9USeaiewzAfPK5JuEY DqkHpgp21esx/y1T+FmYA5hni1ahyczT4Ri7VwY86ME2PBXmrhhISlcTEW+L9xpxQ3pK ESsLi0edr0HKwhp+xnKLbnByUqsnNNhEOlEYiH0D0miX1ggI09FG32zmXh8X9al3hV1h iZK6SFJXBuJKie/iybFLuBV/aK0S6rVLHZ1NSgk6iR7A5kdA8pzAdg/UR04ZkAkHhmIh Knaw== X-Gm-Message-State: AGRZ1gK7iOYBrl6TRFjg/XH3k5oS6SKQGo8CoIOvyn+0AAREr/EwsKzQ XPb04uJgSrNDqlvtC+/JS0gbbA== X-Google-Smtp-Source: AJdET5eE3lhqYtFcuc/vVQm38rEMWqDL5MKVJOqUHmRXufVODzt+Jw0PWJZWV5vX68WXaiJsIH5AtQ== X-Received: by 2002:a5d:634f:: with SMTP id b15-v6mr250479wrw.14.1542014966022; Mon, 12 Nov 2018 01:29:26 -0800 (PST) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id f12-v6sm3228734wru.63.2018.11.12.01.29.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 01:29:25 -0800 (PST) Date: Mon, 12 Nov 2018 10:29:05 +0100 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Thomas Monjalon Cc: dev@dpdk.org, wisamm@mellanox.com, stable@dpdk.org Message-ID: <20181112092905.g5vxszu5okxz4pzn@bidouze.vm.6wind.com> References: <20181111235856.31429-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181111235856.31429-1-thomas@monjalon.net> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH] pci: fix parsing of address without function number 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: , X-List-Received-Date: Mon, 12 Nov 2018 09:29:26 -0000 On Mon, Nov 12, 2018 at 12:58:56AM +0100, Thomas Monjalon wrote: > If the last part of the PCI address (function number) is missing, > the parsing was successful, assuming function 0. > The call to strtoul is not returning an error in such a case, > so an explicit check is inserted before. > > This bug has always been there in older parsing macros: > - GET_PCIADDR_FIELD > - GET_BLACKLIST_FIELD > Returning 0, that's understandable, but errno not being set is rather lame from strtoul. > Fixes: af75078fece3 ("first public release") > Cc: stable@dpdk.org > > Reported-by: Wisam Jaddo > Signed-off-by: Thomas Monjalon Acked-by: Gaetan Rivet > --- > lib/librte_pci/rte_pci.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/lib/librte_pci/rte_pci.c b/lib/librte_pci/rte_pci.c > index 530738dbd..f400178bb 100644 > --- a/lib/librte_pci/rte_pci.c > +++ b/lib/librte_pci/rte_pci.c > @@ -30,6 +30,10 @@ get_u8_pciaddr_field(const char *in, void *_u8, char dlm) > uint8_t *u8 = _u8; > char *end; > > + /* empty string is an error though strtoul() returns 0 */ > + if (*in == '\0') > + return NULL; > + > errno = 0; > val = strtoul(in, &end, 16); > if (errno != 0 || end[0] != dlm || val > UINT8_MAX) { > -- > 2.19.0 > -- Gaëtan Rivet 6WIND