Commit 76483980 authored by Colin Ian King's avatar Colin Ian King Committed by Jakub Kicinski

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: 55307fcb ("octeontx2-af: Add mbox messages to install and delete MCAM rules")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20201118143803.463297-1-colin.king@canonical.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent dd6028a3
...@@ -1218,11 +1218,13 @@ int rvu_mbox_handler_npc_delete_flow(struct rvu *rvu, ...@@ -1218,11 +1218,13 @@ int rvu_mbox_handler_npc_delete_flow(struct rvu *rvu,
mutex_unlock(&mcam->lock); mutex_unlock(&mcam->lock);
list_for_each_entry_safe(iter, tmp, &del_list, list) { list_for_each_entry_safe(iter, tmp, &del_list, list) {
u16 entry = iter->entry;
/* clear the mcam entry target pcifunc */ /* clear the mcam entry target pcifunc */
mcam->entry2target_pffunc[iter->entry] = 0x0; mcam->entry2target_pffunc[entry] = 0x0;
if (npc_delete_flow(rvu, iter, pcifunc)) if (npc_delete_flow(rvu, iter, pcifunc))
dev_err(rvu->dev, "rule deletion failed for entry:%d", dev_err(rvu->dev, "rule deletion failed for entry:%u",
iter->entry); entry);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment