Commit 71f6a85a authored by Neerav Parikh's avatar Neerav Parikh Committed by Jeff Kirsher
Browse files

i40e: Fix static checker warning

This patch fixes the following static checker warning:

  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: default avatarDan Carpenter <>
Signed-off-by: default avatarNeerav Parikh <>
Acked-by: default avatarShannon Nelson <>
Signed-off-by: default avatarKevin Scott <>
Signed-off-by: default avatarCatherine Sullivan <>
Tested-by: default avatarKavindya Deegala <>
Tested-By: Jack Morgan<>
Signed-off-by: default avatarJeff Kirsher <>
parent 6982d429
......@@ -332,6 +332,7 @@ i40e_status i40e_lldp_to_dcb_config(u8 *lldpmib,
u16 type;
u16 length;
u16 typelength;
u16 offset = 0;
if (!lldpmib || !dcbcfg)
return I40E_ERR_PARAM;
......@@ -339,15 +340,17 @@ i40e_status i40e_lldp_to_dcb_config(u8 *lldpmib,
/* set to the start of LLDPDU */
lldpmib += ETH_HLEN;
tlv = (struct i40e_lldp_org_tlv *)lldpmib;
while (tlv) {
while (1) {
typelength = ntohs(tlv->typelength);
type = (u16)((typelength & I40E_LLDP_TLV_TYPE_MASK) >>
length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >>
offset += sizeof(typelength) + length;
if (type == I40E_TLV_TYPE_END)
break;/* END TLV break out */
/* END TLV or beyond LLDPDU size */
if ((type == I40E_TLV_TYPE_END) || (offset > I40E_LLDPDU_SIZE))
switch (type) {
Supports Markdown
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