netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Kangjie Lu <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: Re: [PATCH] net: mlx5: fix a potential NULL pointer dereference
Date: Mon, 11 Mar 2019 11:06:37 -0300	[thread overview]
Message-ID: <20190311140637.GI22848@ziepe.ca> (raw)
In-Reply-To: <20190311063343.20188-1-kjlu@umn.edu>

On Mon, Mar 11, 2019 at 01:33:43AM -0500, Kangjie Lu wrote:
> 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
> +++ 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");

This is really pointless. Fix stuff like this so it doesn't oops or
don't bother.

Jason

>  	return __get_unaligned_cpu32(fcs_bytes);
>  }

  reply	other threads:[~2019-03-11 14:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-11  6:33 [PATCH] net: mlx5: fix a potential NULL pointer dereference Kangjie Lu
2019-03-11 14:06 ` Jason Gunthorpe [this message]
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=20190311140637.GI22848@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=davem@davemloft.net \
    --cc=kjlu@umn.edu \
    --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;
as well as URLs for NNTP newsgroup(s).