net/sfc: fix double free on encap. transfer flow rule path

Message ID 20201116192303.14791-1-ivan.malov@oktetlabs.ru (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: fix double free on encap. transfer flow rule path |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-testing success Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Ivan Malov Nov. 16, 2020, 7:23 p.m. UTC
  Don't free the outer match spec by its pointer in the parsing context
if it has already been tracked by an entry in the outer rule registry.

Fixes: dadff137931c ("net/sfc: support encap flow items in transfer rules")

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
---
 drivers/net/sfc/sfc_mae.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Andrew Rybchenko Nov. 17, 2020, 7:39 a.m. UTC | #1
On 11/16/20 10:23 PM, Ivan Malov wrote:
> Don't free the outer match spec by its pointer in the parsing context
> if it has already been tracked by an entry in the outer rule registry.
> 
> Fixes: dadff137931c ("net/sfc: support encap flow items in transfer rules")
> 
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
  
Ferruh Yigit Nov. 17, 2020, 1:34 p.m. UTC | #2
On 11/17/2020 7:39 AM, Andrew Rybchenko wrote:
> On 11/16/20 10:23 PM, Ivan Malov wrote:
>> Don't free the outer match spec by its pointer in the parsing context
>> if it has already been tracked by an entry in the outer rule registry.
>>
>> Fixes: dadff137931c ("net/sfc: support encap flow items in transfer rules")
>>
>> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> 
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> 

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c
index c78a376a8..4ddfef556 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -1607,6 +1607,9 @@  sfc_mae_rule_process_outer(struct sfc_adapter *sa,
 		}
 	}
 
+	/* The spec has now been tracked by the outer rule entry. */
+	ctx->match_spec_outer = NULL;
+
 	/*
 	 * Depending on whether we reuse an existing outer rule or create a
 	 * new one (see above), outer rule ID is either a valid value or
@@ -1717,7 +1720,8 @@  sfc_mae_rule_encap_parse_fini(struct sfc_adapter *sa,
 	if (ctx->encap_type == EFX_TUNNEL_PROTOCOL_NONE)
 		return;
 
-	efx_mae_match_spec_fini(sa->nic, ctx->match_spec_outer);
+	if (ctx->match_spec_outer != NULL)
+		efx_mae_match_spec_fini(sa->nic, ctx->match_spec_outer);
 }
 
 int