net/pfe: do not use a possibly NULL Pointer
PATCH 1/1 net/pfe: do not use a possibly NULL Pointer
Use dev only after it was checked not to be NULL.
--- drivers/net/pfe/pfe_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/pfe/pfe_ethdev.c +2 -1
@@ -578,7 +578,7 @@ static int pfe_eth_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) { int ret, ioctl_cmd = 0; -struct pfe_eth_priv_s *priv = dev->data->dev_private; +struct pfe_eth_priv_s *priv;struct rte_eth_link link, old;unsigned int lstatus =1 ;
@@ -586,6 +586,7 @@ pfe_eth_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)PFE_PMD_ERR ("Invalid device in link_update.\n" );return 0 ; } + priv = dev->data->dev_private;memset (&old,0 ,sizeof (old));memset (&link,0 ,sizeof (struct rte_eth_link ));
Signature · 1 line
2.29.2
Quoted 37 lines
-----Original Message-----
From: Thierry Herbelot <[email protected]>
Sent: Monday, May 24, 2021 2:29 PM
To: [email protected]
Cc: Thierry Herbelot <[email protected]>; Thomas Monjalon <[email protected]>; [email protected]; Gagandeep Singh <[email protected]>
Subject: [PATCH] net/pfe: do not use a possibly NULL PointerUse dev only after it was checked not to be NULL.
Fixes acd4818ea2a45 ("net/pfe: add link status update")Cc Gagandeep Singh <[email protected]>Signed-off-by Thierry Herbelot <[email protected]>--- drivers/net/pfe/pfe_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/pfe/pfe_ethdev.c +1
-1@@ -578,7 +578,7 @@ static int pfe_eth_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) { int ret, ioctl_cmd = 0; -struct pfe_eth_priv_s *priv = dev->data->dev_private; +struct pfe_eth_priv_s *priv;struct rte_eth_link link, old;unsigned int lstatus =1 ;
drivers/net/pfe/pfe_ethdev.c pfe_eth_link_update(struct rte_eth_dev *dev, int · line 590
Quoted 5 lines
drivers/net/pfe/pfe_ethdev.c +1
-0@@ -586,6 +586,7 @@ pfe_eth_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) PFE_PMD_ERR("Invalid device in link_update.\n");return 0 ; } + priv = dev->data->dev_private;
"dev" will never be NULL here because librte_ethdev library is already doing some checks on dev before calling the link update. So please remove the if check.
Quoted 5 lines
drivers/net/pfe/pfe_ethdev.c +0
-1memset (&old,0 ,sizeof (old));memset (&link,0 ,sizeof (struct rte_eth_link )); --2.29.2
PATCH v2 1/1 net/pfe: no need to check dev to be NULL Pointer
In reply to Thierry Herbelotlibrte_ethdev library is already doing some checks on dev before calling the link update.
--
V2: rework after noting dev cannot be NULL
--- drivers/net/pfe/pfe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/pfe/pfe_ethdev.c +0 -5
@@ -582,11 +582,6 @@ pfe_eth_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)struct rte_eth_link link, old;unsigned int lstatus =1 ; -if (dev ==NULL ) { -PFE_PMD_ERR ("Invalid device in link_update.\n" ); -return 0 ; - } -memset (&old,0 ,sizeof (old));memset (&link,0 ,sizeof (struct rte_eth_link ));
Signature · 1 line
2.29.2
Re: [dpdk-dev] [PATCH v2] net/pfe: no need to check dev to be NULL Pointer
Quoted 14 lines
-----Original Message-----
From: Thierry Herbelot <[email protected]>
Sent: Monday, May 24, 2021 3:08 PM
To: [email protected]
Cc: Thierry Herbelot <[email protected]>; Thomas Monjalon <[email protected]>; [email protected]; Gagandeep Singh <[email protected]>
Subject: [PATCH v2] net/pfe: no need to check dev to be NULL Pointer
librte_ethdevlibrary is already doing some checks on dev before calling the link update.
Quoted 8 lines
Fixes acd4818ea2a45 ("net/pfe: add link status update")Cc Gagandeep Singh <[email protected]>Signed-off-by Thierry Herbelot <[email protected]>--
V2: rework after noting dev cannot be NULL
---
Quoted 22 lines
drivers/net/pfe/pfe_ethdev.c | 5 ----- 1 file changed, 5 deletions(-)drivers/net/pfe/pfe_ethdev.c +0
-6@@ -582,11 +582,6 @@ pfe_eth_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused)struct rte_eth_link link, old;unsigned int lstatus =1 ; -if (dev ==NULL ) { -PFE_PMD_ERR ("Invalid device in link_update.\n" ); -return 0 ; - } -memset (&old,0 ,sizeof (old));memset (&link,0 ,sizeof (struct rte_eth_link )); --2.29.2
Andrew Rybchenko
AppliedRe: [dpdk-dev] [PATCH v2] net/pfe: no need to check dev to be NULL Pointer
Quoted 18 lines · Gagandeep Singh
Quoted 18 lines
-----Original Message-----
From: Thierry Herbelot <[email protected]>
Sent: Monday, May 24, 2021 3:08 PM
To: [email protected]
Cc: Thierry Herbelot <[email protected]>; Thomas Monjalon <[email protected]>; [email protected]; Gagandeep Singh <[email protected]>
Subject: [PATCH v2] net/pfe: no need to check dev to be NULL Pointer
librte_ethdevlibrary is already doing some checks on dev before calling the link update.Fixes acd4818ea2a45 ("net/pfe: add link status update")Cc Gagandeep Singh <[email protected]>
Quoted 6 lines
Quoted 4 lines
Signed-off-by Thierry Herbelot <[email protected]>--
V2: rework after noting dev cannot be NULL
---Acked-by Gagandeep Singh <[email protected]>
Applied, thanks.