From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Neerav Parikh <Neerav.Parikh@intel.com>,
netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com,
Kevin Scott <kevin.c.scott@intel.com>,
Catherine Sullivan <catherine.sullivan@intel.com>,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next v2 09/12] i40e: Fix static checker warning
Date: Thu, 6 Mar 2014 18:59:21 -0800 [thread overview]
Message-ID: <1394161164-26645-10-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1394161164-26645-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Neerav Parikh <Neerav.Parikh@intel.com>
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>
---
drivers/net/ethernet/intel/i40e/i40e_dcb.c | 9 ++++++---
1 file 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 5073014..036570d 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,
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) >>
I40E_LLDP_TLV_TYPE_SHIFT);
length = (u16)((typelength & I40E_LLDP_TLV_LEN_MASK) >>
I40E_LLDP_TLV_LEN_SHIFT);
+ 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))
+ break;
switch (type) {
case I40E_TLV_TYPE_ORG:
--
1.8.3.1
next prev parent reply other threads:[~2014-03-07 2:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 2:59 [net-next v2 00/12][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2014-03-07 2:59 ` [net-next v2 01/12] i40evf: Enable the ndo_set_features netdev op Jeff Kirsher
2014-03-07 2:59 ` [net-next v2 02/12] i40e: Flow Director sideband accounting Jeff Kirsher
2014-03-07 2:59 ` [net-next v2 03/12] i40e: Prevent overflow due to kzalloc Jeff Kirsher
2014-03-07 2:59 ` [net-next v2 04/12] i40e/i40evf: i40e implementation for skb_set_hash Jeff Kirsher
2014-03-07 2:59 ` [net-next v2 05/12] i40e: clean up comment style Jeff Kirsher
2014-03-07 2:59 ` [net-next v2 06/12] i40e: Remove a FW workaround for Number of MSIX vectors Jeff Kirsher
2014-03-07 2:59 ` [net-next v2 07/12] i40e: count timeout events Jeff Kirsher
2014-03-07 2:59 ` [net-next v2 08/12] i40e: Remove a redundant filter addition Jeff Kirsher
2014-03-07 2:59 ` Jeff Kirsher [this message]
2014-03-07 2:59 ` [net-next v2 10/12] i40e: fix nvm version and remove firmware report Jeff Kirsher
2014-03-07 2:59 ` [net-next v2 11/12] i40e/i40evf: carefully fill tx ring Jeff Kirsher
2014-03-09 19:52 ` Ben Hutchings
2014-03-07 2:59 ` [net-next v2 12/12] i40e/i40evf: Bump pf&vf build versions Jeff Kirsher
2014-03-07 21:19 ` [net-next v2 00/12][pull request] Intel Wired LAN Driver Updates David Miller
2014-03-07 21:37 ` Jeff Kirsher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394161164-26645-10-git-send-email-jeffrey.t.kirsher@intel.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=Neerav.Parikh@intel.com \
--cc=catherine.sullivan@intel.com \
--cc=davem@davemloft.net \
--cc=gospo@redhat.com \
--cc=kevin.c.scott@intel.com \
--cc=netdev@vger.kernel.org \
--cc=sassmann@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).