octeontx2-af: Fix access of iter->entry after iter object has been kfree'd
authorColin Ian King <colin.king@canonical.com>
Wed, 18 Nov 2020 14:38:03 +0000 (14:38 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 20 Nov 2020 19:07:57 +0000 (11:07 -0800)
commit76483980174c6ff80cc4d02a444f2815073d203d
treeabcdce5aa1151a6275d78f0c1b2eca647ba0827a
parentdd6028a3cb5da85d6c8ff20a593a7a70d10d650c
octeontx2-af: Fix access of iter->entry after iter object has been kfree'd

The call to pc_delete_flow can kfree the iter object, so the following
dev_err message that accesses iter->entry can accessmemory that has
just been kfree'd.  Fix this by adding a temporary variable 'entry'
that has a copy of iter->entry and also use this when indexing into
the array mcam->entry2target_pffunc[]. Also print the unsigned value
using the %u format specifier rather than %d.

Addresses-Coverity: ("Read from pointer after free")
Fixes: 55307fcb9258 ("octeontx2-af: Add mbox messages to install and delete MCAM rules")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20201118143803.463297-1-colin.king@canonical.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c