* [PATCH] net/mlx5e: Fix freeing of unassigned pointer
@ 2020-10-03 11:10 Alex Dewar
2020-10-06 23:22 ` Saeed Mahameed
0 siblings, 1 reply; 3+ messages in thread
From: Alex Dewar @ 2020-10-03 11:10 UTC (permalink / raw)
Cc: Alex Dewar, Saeed Mahameed, Leon Romanovsky, David S. Miller,
Jakub Kicinski, Gustavo A. R. Silva, netdev, linux-rdma,
linux-kernel
Commit ff7ea04ad579 ("net/mlx5e: Fix potential null pointer dereference")
added some missing null checks but the error handling in
mlx5e_alloc_flow() was left broken: the variable attr is passed to kfree
although it is never assigned to and never needs to be freed in this
function. Fix this.
Addresses-Coverity-ID: 1497536 ("Memory - illegal accesses")
Fixes: ff7ea04ad579 ("net/mlx5e: Fix potential null pointer dereference")
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index a0c356987e1a..88298e96c4ea 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -4536,13 +4536,14 @@ 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 err = -ENOMEM;
int out_index;
flow = kzalloc(sizeof(*flow), GFP_KERNEL);
+ if (!flow)
+ return -ENOMEM;
parse_attr = kvzalloc(sizeof(*parse_attr), GFP_KERNEL);
- if (!parse_attr || !flow)
- goto err_free;
+ if (!parse_attr)
+ goto err_free_flow;
flow->flags = flow_flags;
flow->cookie = f->cookie;
@@ -4550,7 +4551,7 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size,
attr = mlx5_alloc_flow_attr(get_flow_name_space(flow));
if (!attr)
- goto err_free;
+ goto err_free_parse_attr;
flow->attr = attr;
@@ -4566,11 +4567,11 @@ mlx5e_alloc_flow(struct mlx5e_priv *priv, int attr_size,
return 0;
-err_free:
- kfree(flow);
+err_free_parse_attr:
kvfree(parse_attr);
- kfree(attr);
- return err;
+err_free_flow:
+ kfree(flow);
+ return -ENOMEM;
}
static void
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net/mlx5e: Fix freeing of unassigned pointer
2020-10-03 11:10 [PATCH] net/mlx5e: Fix freeing of unassigned pointer Alex Dewar
@ 2020-10-06 23:22 ` Saeed Mahameed
2020-10-07 9:13 ` Alex Dewar
0 siblings, 1 reply; 3+ messages in thread
From: Saeed Mahameed @ 2020-10-06 23:22 UTC (permalink / raw)
To: Alex Dewar
Cc: Leon Romanovsky, David S. Miller, Jakub Kicinski,
Gustavo A. R. Silva, netdev, linux-rdma, linux-kernel
On Sat, 2020-10-03 at 12:10 +0100, Alex Dewar wrote:
> Commit ff7ea04ad579 ("net/mlx5e: Fix potential null pointer
> dereference")
> added some missing null checks but the error handling in
> mlx5e_alloc_flow() was left broken: the variable attr is passed to
> kfree
> although it is never assigned to and never needs to be freed in this
> function. Fix this.
>
> Addresses-Coverity-ID: 1497536 ("Memory - illegal accesses")
> Fixes: ff7ea04ad579 ("net/mlx5e: Fix potential null pointer
> dereference")
> Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 17 +++++++++----
> ----
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
Hi Alex, thanks for the patch,
Colin submitted a one liner patch that I already picked up.
I hope you are ok with this.
Thanks,
Saeed.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net/mlx5e: Fix freeing of unassigned pointer
2020-10-06 23:22 ` Saeed Mahameed
@ 2020-10-07 9:13 ` Alex Dewar
0 siblings, 0 replies; 3+ messages in thread
From: Alex Dewar @ 2020-10-07 9:13 UTC (permalink / raw)
To: Saeed Mahameed
Cc: Alex Dewar, Leon Romanovsky, David S. Miller, Jakub Kicinski,
Gustavo A. R. Silva, netdev, linux-rdma, linux-kernel
On Tue, Oct 06, 2020 at 04:22:12PM -0700, Saeed Mahameed wrote:
> On Sat, 2020-10-03 at 12:10 +0100, Alex Dewar wrote:
> > Commit ff7ea04ad579 ("net/mlx5e: Fix potential null pointer
> > dereference")
> > added some missing null checks but the error handling in
> > mlx5e_alloc_flow() was left broken: the variable attr is passed to
> > kfree
> > although it is never assigned to and never needs to be freed in this
> > function. Fix this.
> >
> > Addresses-Coverity-ID: 1497536 ("Memory - illegal accesses")
> > Fixes: ff7ea04ad579 ("net/mlx5e: Fix potential null pointer
> > dereference")
> > Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> > ---
> > drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 17 +++++++++----
> > ----
> > 1 file changed, 9 insertions(+), 8 deletions(-)
> >
>
> Hi Alex, thanks for the patch,
> Colin submitted a one liner patch that I already picked up.
>
> I hope you are ok with this.
Hi Saeed,
Sure. As long as attr is no longer being freed then that should fix the
problem.
Best,
Alex
>
> Thanks,
> Saeed.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-07 9:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-03 11:10 [PATCH] net/mlx5e: Fix freeing of unassigned pointer Alex Dewar
2020-10-06 23:22 ` Saeed Mahameed
2020-10-07 9:13 ` Alex Dewar
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).