lkml.org 
[lkml]   [2019]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] net: mlx5: fix a potential NULL pointer dereference
Date
On Mon, 2019-03-11 at 01:33 -0500, Kangjie Lu wrote:
> In case skb_header_pointer fails, the fix issues a warning.
>

This case is impossible: mlx5 driver builds this skb itself so we are
sure skb_header_pointer never fails.

What is the motivation behind this fix? static checker or actual issue
?

> 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);
> }
\
 
 \ /
  Last update: 2019-03-11 19:47    [W:0.124 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site