net/cnxk: fix crash in IPsec telemetry

Message ID 20220519122151.3119730-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series net/cnxk: fix crash in IPsec telemetry |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS

Commit Message

David Marchand May 19, 2022, 12:21 p.m. UTC
  Calling this telemetry callback with no argument caused a crash.

Fixes: 41cc645c214f ("net/cnxk: add inline IPsec telemetry for CN9K")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Jerin Jacob June 13, 2022, 12:44 p.m. UTC | #1
On Thu, May 19, 2022 at 5:52 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> Calling this telemetry callback with no argument caused a crash.
>
> Fixes: 41cc645c214f ("net/cnxk: add inline IPsec telemetry for CN9K")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>


Applied to dpdk-next-net-mrvl/for-next-net. Thanks


> ---
>  drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
> index dfad5af8fe..bfdbd1ee5d 100644
> --- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
> +++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
> @@ -229,6 +229,9 @@ ethdev_sec_tel_handle_info(const char *cmd __rte_unused, const char *params,
>         uint32_t i;
>         int ret;
>
> +       if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> +               return -EINVAL;
> +
>         port_id = strtoul(params, &end_p, 0);
>         if (errno != 0)
>                 return -EINVAL;
> --
> 2.36.1
>
  

Patch

diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
index dfad5af8fe..bfdbd1ee5d 100644
--- a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
+++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c
@@ -229,6 +229,9 @@  ethdev_sec_tel_handle_info(const char *cmd __rte_unused, const char *params,
 	uint32_t i;
 	int ret;
 
+	if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+		return -EINVAL;
+
 	port_id = strtoul(params, &end_p, 0);
 	if (errno != 0)
 		return -EINVAL;