mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 18:05:21 +02:00
net: microchip: vcap: Fix use-after-free error in kunit test
commita3c1e45156
upstream. 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 <error27@gmail.com> Closes: https://lore.kernel.org/kernel-janitors/7bffefc6-219a-4f71-baa0-ad4526e5c198@kili.mountain/ Fixes:c956b9b318
("net: microchip: sparx5: Adding KUNIT tests of key/action values in VCAP API") Signed-off-by: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
dde33a9d0b
commit
b0804c286c
|
@ -1442,18 +1442,8 @@ static void vcap_api_encode_rule_test(struct kunit *test)
|
||||||
vcap_enable_lookups(&test_vctrl, &test_netdev, 0, 0,
|
vcap_enable_lookups(&test_vctrl, &test_netdev, 0, 0,
|
||||||
rule->cookie, false);
|
rule->cookie, false);
|
||||||
|
|
||||||
vcap_free_rule(rule);
|
ret = vcap_del_rule(&test_vctrl, &test_netdev, id);
|
||||||
|
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||||
/* Check that the rule has been freed: tricky to access since this
|
|
||||||
* memory should not be accessible anymore
|
|
||||||
*/
|
|
||||||
KUNIT_EXPECT_PTR_NE(test, NULL, rule);
|
|
||||||
ret = list_empty(&rule->keyfields);
|
|
||||||
KUNIT_EXPECT_EQ(test, true, ret);
|
|
||||||
ret = list_empty(&rule->actionfields);
|
|
||||||
KUNIT_EXPECT_EQ(test, true, ret);
|
|
||||||
|
|
||||||
vcap_del_rule(&test_vctrl, &test_netdev, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vcap_api_set_rule_counter_test(struct kunit *test)
|
static void vcap_api_set_rule_counter_test(struct kunit *test)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user