* [dpdk-dev] [PATCH] pci: fix parsing of address without function number
@ 2018-11-11 23:58 Thomas Monjalon
2018-11-12 9:29 ` Gaëtan Rivet
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Monjalon @ 2018-11-11 23:58 UTC (permalink / raw)
To: gaetan.rivet; +Cc: dev, wisamm, stable
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
Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Reported-by: Wisam Jaddo <wisamm@mellanox.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] pci: fix parsing of address without function number
2018-11-11 23:58 [dpdk-dev] [PATCH] pci: fix parsing of address without function number Thomas Monjalon
@ 2018-11-12 9:29 ` Gaëtan Rivet
2018-11-13 17:00 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Gaëtan Rivet @ 2018-11-12 9:29 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev, wisamm, stable
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 <wisamm@mellanox.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] pci: fix parsing of address without function number
2018-11-12 9:29 ` Gaëtan Rivet
@ 2018-11-13 17:00 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2018-11-13 17:00 UTC (permalink / raw)
To: Gaëtan Rivet; +Cc: dev, wisamm, stable
12/11/2018 10:29, Gaëtan Rivet:
> 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 <wisamm@mellanox.com>
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Gaetan Rivet <gaetan.rivet@6wind.com>
Applied
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-13 17:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-11 23:58 [dpdk-dev] [PATCH] pci: fix parsing of address without function number Thomas Monjalon
2018-11-12 9:29 ` Gaëtan Rivet
2018-11-13 17:00 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).