diff options
author | Neerav Parikh <Neerav.Parikh@intel.com> | 2014-02-06 00:51:11 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2014-03-06 21:41:50 -0500 |
commit | 71f6a85a5881b30ba80d3dac5173f1a6c55c8ccf (patch) | |
tree | f0851a2e248a51e0bcd3513acca37265c68c3999 /drivers/net/ethernet/intel/i40e | |
parent | 6982d429a9194e5069c5249e751422def87658a6 (diff) |
i40e: Fix static checker warning
This patch fixes the following static checker warning:
drivers/net/ethernet/intel/i40e/i40e_dcb.c:342
i40e_lldp_to_dcb_config() warn: 'tlv' can't be NULL.
Exit criteria from the while loop is encountering LLDP END
LV or if the TLV length goes beyond the buffer length.
Change-ID: I7548b16db90230ec2ba0fa791b0343ca8b7dd5bb
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Neerav Parikh <Neerav.Parikh@intel.com>
Acked-by: Shannon Nelson <shannon.nelson@intel.com>
Signed-off-by: Kevin Scott <kevin.c.scott@intel.com>
Signed-off-by: Catherine Sullivan <catherine.sullivan@intel.com>
Tested-by: Kavindya Deegala <kavindya.s.deegala@intel.com>
Tested-By: Jack Morgan<jack.morgan@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/i40e')
-rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_dcb.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_dcb.c b/drivers/net/ethernet/intel/i40e/i40e_dcb.c index 50730141bb7b..036570d76176 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_dcb.c +++ b/drivers/net/ethernet/intel/i40e/i40e_dcb.c | |||
@@ -332,6 +332,7 @@ i40e_status i40e_lldp_to_dcb_config(u8 *lldpmib, | |||
332 | u16 type; | 332 | u16 type; |
333 | u16 length; | 333 | u16 length; |
334 | u16 typelength; | 334 | u16 typelength; |
335 | u16 offset = 0; | ||
335 | 336 | ||
336 | if (!lldpmib || !dcbcfg) | 337 | if (!lldpmib || !dcbcfg) |
337 | return I40E_ERR_PARAM; | 338 | return I40E_ERR_PARAM; |
@@ -339,15 +340,17 @@ i40e_status i40e_lldp_to_dcb_config(u8 *lldpmib, | |||
339 | /* set to the start of LLDPDU */ | 340 | /* set to the start of LLDPDU */ |
340 | lldpmib += ETH_HLEN; | 341 | lldpmib += ETH_HLEN; |
341 | tlv = (struct i40e_lldp_org_tlv *)lldpmib; | 342 | tlv = (struct i40e_lldp_org_tlv *)lldpmib; |
342 | while (tlv) { | 343 | while (1) { |
343 | typelength = ntohs(tlv->typelength); | 344 | typelength = ntohs(tlv->typelength); |
344 | type = (u16)((typelength & I40E_LLDP_TLV_TYPE_MASK) >> | 345 | type = (u16)((typelength & I40E_LLDP_TLV_TYPE_MASK) >> |
345 | I40E_LLDP_TLV_TYPE_SHIFT); | 346 | I40E_LLDP_TLV_TYPE_SHIFT); |
346 | length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >> | 347 | length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >> |
347 | I40E_LLDP_TLV_LEN_SHIFT); | 348 | I40E_LLDP_TLV_LEN_SHIFT); |
349 | offset += sizeof(typelength) + length; | ||
348 | 350 | ||
349 | if (type == I40E_TLV_TYPE_END) | 351 | /* END TLV or beyond LLDPDU size */ |
350 | break;/* END TLV break out */ | 352 | if ((type == I40E_TLV_TYPE_END) || (offset > I40E_LLDPDU_SIZE)) |
353 | break; | ||
351 | 354 | ||
352 | switch (type) { | 355 | switch (type) { |
353 | case I40E_TLV_TYPE_ORG: | 356 | case I40E_TLV_TYPE_ORG: |