Skip to content

Commit a3c1e45

Browse files
jeso-mchpdavem330
authored andcommitted
net: microchip: vcap: Fix use-after-free error in kunit test
This is a clear use-after-free error. We remove it, and rely on checking the return code of vcap_del_rule. Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/kernel-janitors/[email protected]/ Fixes: c956b9b ("net: microchip: sparx5: Adding KUNIT tests of key/action values in VCAP API") Signed-off-by: Jens Emil Schulz Østergaard <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9b08742 commit a3c1e45

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,18 +1442,8 @@ static void vcap_api_encode_rule_test(struct kunit *test)
14421442
vcap_enable_lookups(&test_vctrl, &test_netdev, 0, 0,
14431443
rule->cookie, false);
14441444

1445-
vcap_free_rule(rule);
1446-
1447-
/* Check that the rule has been freed: tricky to access since this
1448-
* memory should not be accessible anymore
1449-
*/
1450-
KUNIT_EXPECT_PTR_NE(test, NULL, rule);
1451-
ret = list_empty(&rule->keyfields);
1452-
KUNIT_EXPECT_EQ(test, true, ret);
1453-
ret = list_empty(&rule->actionfields);
1454-
KUNIT_EXPECT_EQ(test, true, ret);
1455-
1456-
vcap_del_rule(&test_vctrl, &test_netdev, id);
1445+
ret = vcap_del_rule(&test_vctrl, &test_netdev, id);
1446+
KUNIT_EXPECT_EQ(test, 0, ret);
14571447
}
14581448

14591449
static void vcap_api_set_rule_counter_test(struct kunit *test)

0 commit comments

Comments
 (0)