]> git.baikalelectronics.ru Git - kernel.git/commit
i40e: remove out-of-range comparisons in i40e_validate_cloud_filter
authorJacob Keller <jacob.e.keller@intel.com>
Thu, 28 Feb 2019 17:52:53 +0000 (09:52 -0800)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Fri, 3 May 2019 21:31:39 +0000 (14:31 -0700)
commitc2dedef0a1d89bc4900eed30b85cff1142130b23
treef104814d3df9a34329fd688c9e9762fed576c3f1
parent7370cf72f7a2af5e351aff27f388dd4b4c5e8627
i40e: remove out-of-range comparisons in i40e_validate_cloud_filter

The function i40e_validate_cloud_filter checks that the destination and
source port numbers are valid by attempting to ensure that the number is
non-zero and no larger than 0xFFFF. However, the types for the dst_port
and src_port variable are __be16 which by definition cannot be larger
than 0xFFFF

Since these values cannot be larger than 2 bytes, the check to see if
they exceed 0xFFFF is meaningless.

One might consider these checks as some sort of defensive coding, in
case the type was later changed. However, these checks also byte-swap
the value before comparison using be16_to_cpu, which will truncate the
values to 16bits anyways. Additionally, changing the type would require
updating the opcodes to support new data layout of these virtchnl
commands.

Remove the check to silence the -Wtype-limits warning that was added to
GCC 8.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c