On 9/22/2020 6:20 PM, Kevin Laatz wrote:
Add a check for the return value of the sscanf call in
parse_internal_args(), returning an error if we don't get the expected
result.

Coverity issue: 362049
Fixes: 96cb19521147 ("net/ring: use EAL APIs in PMD specific API")
Cc: [email protected]

Signed-off-by: Kevin Laatz <[email protected]>
---
  drivers/net/ring/rte_eth_ring.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index 40fe1ca4ba..62060e46ce 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -539,7 +539,8 @@ parse_internal_args(const char *key __rte_unused, const 
char *value,
        struct ring_internal_args **internal_args = data;
        void *args;
- sscanf(value, "%p", &args);
+       if (sscanf(value, "%p", &args) != 1)
+               return -1;

I am aware that this is just to fix the coverity error to check the return value, BUT :)

The internal args is mainly to pass the information get by API ('rte_eth_from_ring()') to ring probe. And the main information to pass is the ring. It may be possible to pass the ring_name only and eliminate internal args completely, the driver already has a way to pass ring name:
"nodeaction=name:node:ATTACH" devargs.

If you have time, can you please check if it can be possible to fill and pass the nodeaction devargs in 'rte_eth_from_rings()' and eliminate the 'internal' devargs completely? If it works, as a bonus it will resolve above coverity issue by removing it :)

Reply via email to