Skip to content

Commit

Permalink
net/qede: fix use after free
Browse files Browse the repository at this point in the history
The loop cleaning up flowdir resources was using SLIST_FOREACH
but the inner loop would call rte_free. Found by building with
address sanitizer undefined check.

Also remove needless initialization, and null check.

Fixes: f5765f6 ("net/qede: refactor flow director into generic aRFS")
Cc: [email protected]
Cc: [email protected]

Signed-off-by: Stephen Hemminger <[email protected]>
  • Loading branch information
shemminger authored and raslandarawsheh committed Jan 29, 2025
1 parent 95a3e16 commit 167e4e2
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions drivers/net/qede/qede_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
#include <rte_errno.h>
#include <rte_flow_driver.h>

#ifndef SLIST_FOREACH_SAFE
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = SLIST_FIRST((head)); \
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
(var) = (tvar))
#endif

#include "qede_ethdev.h"

/* VXLAN tunnel classification mapping */
Expand Down Expand Up @@ -154,15 +161,12 @@ int qede_check_fdir_support(struct rte_eth_dev *eth_dev)
void qede_fdir_dealloc_resc(struct rte_eth_dev *eth_dev)
{
struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
struct qede_arfs_entry *tmp = NULL;
struct qede_arfs_entry *tmp, *tmp2;

SLIST_FOREACH(tmp, &qdev->arfs_info.arfs_list_head, list) {
if (tmp) {
rte_memzone_free(tmp->mz);
SLIST_REMOVE(&qdev->arfs_info.arfs_list_head, tmp,
qede_arfs_entry, list);
rte_free(tmp);
}
SLIST_FOREACH_SAFE(tmp, &qdev->arfs_info.arfs_list_head, list, tmp2) {
rte_memzone_free(tmp->mz);
SLIST_REMOVE(&qdev->arfs_info.arfs_list_head, tmp, qede_arfs_entry, list);
rte_free(tmp);
}
}

Expand Down

0 comments on commit 167e4e2

Please sign in to comment.