iavf: prevent accidental free of filter structure
authorJacob Keller <jacob.e.keller@intel.com>
Fri, 4 Jun 2021 16:48:57 +0000 (09:48 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 15 Nov 2021 23:40:04 +0000 (15:40 -0800)
commit4f0400803818f2642f066d3eacaf013f23554cc7
treefc8f5e3a45ffce5f241a841b4cae311305bd510c
parent8905072a192fffe9389255489db250c73ecab008
iavf: prevent accidental free of filter structure

In iavf_config_clsflower, the filter structure could be accidentally
released at the end, if iavf_parse_cls_flower or iavf_handle_tclass ever
return a non-zero but positive value.

In this case, the function continues through to the end, and will call
kfree() on the filter structure even though it has been added to the
linked list.

This can actually happen because iavf_parse_cls_flower will return
a positive IAVF_ERR_CONFIG value instead of the traditional negative
error codes.

Fix this by ensuring that the kfree() check and error checks are
similar. Use the more idiomatic "if (err)" to catch all non-zero error
codes.

Fixes: 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Tony Brelinski <tony.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/iavf/iavf_main.c