public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Kangjie Lu <kjlu@umn.edu>
To: kjlu@umn.edu
Cc: pakki001@umn.edu, Saeed Mahameed <saeedm@mellanox.com>,
	Leon Romanovsky <leon@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] net: mlx5: fix a potential NULL pointer dereference
Date: Mon, 11 Mar 2019 01:33:43 -0500	[thread overview]
Message-ID: <20190311063343.20188-1-kjlu@umn.edu> (raw)

In case skb_header_pointer fails, the fix issues a warning.

A better fix requires modifying the signature of mlx5e_get_fcs to
pass an error code upstream.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index be396e5e4e39..6ec1c110e4be 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -719,6 +719,8 @@ static u32 mlx5e_get_fcs(const struct sk_buff *skb)
 
 	fcs_bytes = skb_header_pointer(skb, skb->len - ETH_FCS_LEN,
 				       ETH_FCS_LEN, &_fcs_bytes);
+	if (unlikely(!fcs_bytes))
+		pr_warn_once("skb_header_pointer returns NULL\n");
 
 	return __get_unaligned_cpu32(fcs_bytes);
 }
-- 
2.17.1

             reply	other threads:[~2019-03-11  6:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11  6:33 Kangjie Lu [this message]
2019-03-11 14:06 ` [PATCH] net: mlx5: fix a potential NULL pointer dereference Jason Gunthorpe
2019-03-11 18:46 ` Saeed Mahameed
2019-03-11 20:38 ` David Miller

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=20190311063343.20188-1-kjlu@umn.edu \
    --to=kjlu@umn.edu \
    --cc=davem@davemloft.net \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pakki001@umn.edu \
    --cc=saeedm@mellanox.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