patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH 1/2] common/mlx5: fix miss null check in devargs parsing
       [not found] <20221024123335.3163331-1-michaelba@nvidia.com>
@ 2022-10-24 12:33 ` Michael Baum
  2022-10-24 12:33 ` [PATCH 2/2] net/mlx5: fix miss null check in ETH " Michael Baum
  1 sibling, 0 replies; 2+ messages in thread
From: Michael Baum @ 2022-10-24 12:33 UTC (permalink / raw)
  To: dev
  Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko, michaelba, stable

The common MLX5 probe function parses first the devargs and save them in
a dictionary.
It gets structure called "devargs" as a member of EAL device containing
all needed information.

When "devargs" structure is invalid, the function avoids parsing it.
However, when it valid but its field "args" is invalid, the function
tries to parse it and dereference to NULL pointer.

This patch adds check to avoid this NULL dereferencing.

Fixes: a729d2f093e9 ("common/mlx5: refactor devargs management")
Cc: michaelba@nvidia.com
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/common/mlx5/mlx5_common.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c
index 4dcc8cc49c..bf22c0694d 100644
--- a/drivers/common/mlx5/mlx5_common.c
+++ b/drivers/common/mlx5/mlx5_common.c
@@ -164,8 +164,9 @@ mlx5_kvargs_prepare(struct mlx5_kvargs_ctrl *mkvlist,
 	struct rte_kvargs *kvlist;
 	uint32_t i;
 
-	if (devargs == NULL)
+	if (mkvlist == NULL)
 		return 0;
+	MLX5_ASSERT(devargs != NULL && devargs->args != NULL);
 	kvlist = rte_kvargs_parse(devargs->args, NULL);
 	if (kvlist == NULL) {
 		rte_errno = EINVAL;
@@ -400,8 +401,9 @@ parse_class_options(const struct rte_devargs *devargs,
 {
 	int ret = 0;
 
-	if (devargs == NULL)
+	if (mkvlist == NULL)
 		return 0;
+	MLX5_ASSERT(devargs != NULL);
 	if (devargs->cls != NULL && devargs->cls->name != NULL)
 		/* Global syntax, only one class type. */
 		return class_name_to_value(devargs->cls->name);
@@ -965,7 +967,7 @@ mlx5_common_dev_probe(struct rte_device *eal_dev)
 	int ret;
 
 	DRV_LOG(INFO, "probe device \"%s\".", eal_dev->name);
-	if (eal_dev->devargs != NULL)
+	if (eal_dev->devargs != NULL && eal_dev->devargs->args != NULL)
 		mkvlist_p = &mkvlist;
 	ret = mlx5_kvargs_prepare(mkvlist_p, eal_dev->devargs);
 	if (ret < 0) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] net/mlx5: fix miss null check in ETH devargs parsing
       [not found] <20221024123335.3163331-1-michaelba@nvidia.com>
  2022-10-24 12:33 ` [PATCH 1/2] common/mlx5: fix miss null check in devargs parsing Michael Baum
@ 2022-10-24 12:33 ` Michael Baum
  1 sibling, 0 replies; 2+ messages in thread
From: Michael Baum @ 2022-10-24 12:33 UTC (permalink / raw)
  To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko, xuemingl, stable

The "mlx5_os_parse_eth_devargs()" function parses the ETH devargs into a
specific structure called "eth_da".
It gets structure called "devargs" as a member of EAL device containing
the relevant information.

When "devargs" structure is invalid, the function avoids parsing it.
However, when it valid but its field "args" is invalid, the function
tries to parse it and dereference to NULL pointer.

This patch adds check to avoid this NULL dereferencing.

Fixes: 919488fbfa71 ("net/mlx5: support Sub-Function")
Cc: xuemingl@nvidia.com
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index ab7ffa0931..2b6741396d 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2411,7 +2411,7 @@ mlx5_os_parse_eth_devargs(struct rte_device *dev,
 			dev->devargs->cls_str);
 		return -rte_errno;
 	}
-	if (eth_da->type == RTE_ETH_REPRESENTOR_NONE) {
+	if (eth_da->type == RTE_ETH_REPRESENTOR_NONE && dev->devargs->args) {
 		/* Parse legacy device argument */
 		ret = rte_eth_devargs_parse(dev->devargs->args, eth_da);
 		if (ret) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-24 12:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20221024123335.3163331-1-michaelba@nvidia.com>
2022-10-24 12:33 ` [PATCH 1/2] common/mlx5: fix miss null check in devargs parsing Michael Baum
2022-10-24 12:33 ` [PATCH 2/2] net/mlx5: fix miss null check in ETH " Michael Baum

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).