* [PATCH][next] net/mlx5e: Fix potential null pointer dereference
@ 2020-09-25 16:49 Gustavo A. R. Silva
2020-09-28 7:38 ` Leon Romanovsky
2020-09-28 23:22 ` Saeed Mahameed
0 siblings, 2 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2020-09-25 16:49 UTC (permalink / raw)
To: Saeed Mahameed, Leon Romanovsky, David S. Miller, Jakub Kicinski,
Roi Dayan, Vlad Buslov, Ariel Levkovich
Cc: netdev, linux-rdma, linux-kernel, Gustavo A. R. Silva
Calls to kzalloc() and kvzalloc() should be null-checked
in order to avoid any potential failures. In this case,
a potential null pointer dereference.
Fix this by adding null checks for _parse_attr_ and _flow_
right after allocation.
Addresses-Coverity-ID: 1497154 ("Dereference before null check")
Fixes: c620b772152b ("net/mlx5: Refactor tc flow attributes structure")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index f815b0c60a6c..fb27154bfddb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -4534,20 +4534,22 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size,
struct mlx5e_tc_flow_parse_attr *parse_attr;
struct mlx5_flow_attr *attr;
struct mlx5e_tc_flow *flow;
- int out_index, err;
+ int err = -ENOMEM;
+ int out_index;
flow = kzalloc(sizeof(*flow), GFP_KERNEL);
parse_attr = kvzalloc(sizeof(*parse_attr), GFP_KERNEL);
+ if (!parse_attr || !flow)
+ goto err_free;
flow->flags = flow_flags;
flow->cookie = f->cookie;
flow->priv = priv;
attr = mlx5_alloc_flow_attr(get_flow_name_space(flow));
- if (!parse_attr || !flow || !attr) {
- err = -ENOMEM;
+ if (!attr)
goto err_free;
- }
+
flow->attr = attr;
for (out_index = 0; out_index < MLX5_MAX_FLOW_FWD_VPORTS; out_index++)
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] net/mlx5e: Fix potential null pointer dereference
2020-09-25 16:49 [PATCH][next] net/mlx5e: Fix potential null pointer dereference Gustavo A. R. Silva
@ 2020-09-28 7:38 ` Leon Romanovsky
2020-09-28 23:22 ` Saeed Mahameed
1 sibling, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2020-09-28 7:38 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Saeed Mahameed, David S. Miller, Jakub Kicinski, Roi Dayan,
Vlad Buslov, Ariel Levkovich, netdev, linux-rdma, linux-kernel
On Fri, Sep 25, 2020 at 11:49:13AM -0500, Gustavo A. R. Silva wrote:
> Calls to kzalloc() and kvzalloc() should be null-checked
> in order to avoid any potential failures. In this case,
> a potential null pointer dereference.
>
> Fix this by adding null checks for _parse_attr_ and _flow_
> right after allocation.
>
> Addresses-Coverity-ID: 1497154 ("Dereference before null check")
> Fixes: c620b772152b ("net/mlx5: Refactor tc flow attributes structure")
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] net/mlx5e: Fix potential null pointer dereference
2020-09-25 16:49 [PATCH][next] net/mlx5e: Fix potential null pointer dereference Gustavo A. R. Silva
2020-09-28 7:38 ` Leon Romanovsky
@ 2020-09-28 23:22 ` Saeed Mahameed
2020-09-29 13:13 ` Gustavo A. R. Silva
1 sibling, 1 reply; 4+ messages in thread
From: Saeed Mahameed @ 2020-09-28 23:22 UTC (permalink / raw)
To: Gustavo A. R. Silva, Leon Romanovsky, David S. Miller,
Jakub Kicinski, Roi Dayan, Vlad Buslov, Ariel Levkovich
Cc: netdev, linux-rdma, linux-kernel
On Fri, 2020-09-25 at 11:49 -0500, Gustavo A. R. Silva wrote:
> Calls to kzalloc() and kvzalloc() should be null-checked
> in order to avoid any potential failures. In this case,
> a potential null pointer dereference.
>
> Fix this by adding null checks for _parse_attr_ and _flow_
> right after allocation.
>
> Addresses-Coverity-ID: 1497154 ("Dereference before null check")
> Fixes: c620b772152b ("net/mlx5: Refactor tc flow attributes
> structure")
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
>
Applied to net-next-mlx5.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] net/mlx5e: Fix potential null pointer dereference
2020-09-28 23:22 ` Saeed Mahameed
@ 2020-09-29 13:13 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2020-09-29 13:13 UTC (permalink / raw)
To: Saeed Mahameed
Cc: Leon Romanovsky, David S. Miller, Jakub Kicinski, Roi Dayan,
Vlad Buslov, Ariel Levkovich, netdev, linux-rdma, linux-kernel
On Mon, Sep 28, 2020 at 04:22:33PM -0700, Saeed Mahameed wrote:
> On Fri, 2020-09-25 at 11:49 -0500, Gustavo A. R. Silva wrote:
> > Calls to kzalloc() and kvzalloc() should be null-checked
> > in order to avoid any potential failures. In this case,
> > a potential null pointer dereference.
> >
> > Fix this by adding null checks for _parse_attr_ and _flow_
> > right after allocation.
> >
> > Addresses-Coverity-ID: 1497154 ("Dereference before null check")
> > Fixes: c620b772152b ("net/mlx5: Refactor tc flow attributes
> > structure")
> > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> > ---
> >
>
> Applied to net-next-mlx5.
Thank you both. :)
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-29 13:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25 16:49 [PATCH][next] net/mlx5e: Fix potential null pointer dereference Gustavo A. R. Silva
2020-09-28 7:38 ` Leon Romanovsky
2020-09-28 23:22 ` Saeed Mahameed
2020-09-29 13:13 ` Gustavo A. R. Silva
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).