* [PATCH] nfp: abm: fix a memory leak bug
@ 2020-05-02 22:42 wu000273
2020-05-04 17:01 ` Jakub Kicinski
2020-05-04 19:05 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: wu000273 @ 2020-05-02 22:42 UTC (permalink / raw)
To: kuba; +Cc: davem, oss-drivers, netdev, linux-kernel, kjlu, wu000273
From: Qiushi Wu <wu000273@umn.edu>
In function nfp_abm_vnic_set_mac, pointer nsp is allocated by nfp_nsp_open.
But when nfp_nsp_has_hwinfo_lookup fail, the pointer is not released,
which can lead to a memory leak bug. Fix this issue by adding
nfp_nsp_close(nsp) in the error path.
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
drivers/net/ethernet/netronome/nfp/abm/main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/netronome/nfp/abm/main.c b/drivers/net/ethernet/netronome/nfp/abm/main.c
index 9183b3e85d21..354efffac0f9 100644
--- a/drivers/net/ethernet/netronome/nfp/abm/main.c
+++ b/drivers/net/ethernet/netronome/nfp/abm/main.c
@@ -283,6 +283,7 @@ nfp_abm_vnic_set_mac(struct nfp_pf *pf, struct nfp_abm *abm, struct nfp_net *nn,
if (!nfp_nsp_has_hwinfo_lookup(nsp)) {
nfp_warn(pf->cpp, "NSP doesn't support PF MAC generation\n");
eth_hw_addr_random(nn->dp.netdev);
+ nfp_nsp_close(nsp);
return;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nfp: abm: fix a memory leak bug
2020-05-02 22:42 [PATCH] nfp: abm: fix a memory leak bug wu000273
@ 2020-05-04 17:01 ` Jakub Kicinski
2020-05-04 19:05 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2020-05-04 17:01 UTC (permalink / raw)
To: wu000273; +Cc: davem, oss-drivers, netdev, linux-kernel, kjlu
On Sat, 2 May 2020 17:42:59 -0500 wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
>
> In function nfp_abm_vnic_set_mac, pointer nsp is allocated by nfp_nsp_open.
> But when nfp_nsp_has_hwinfo_lookup fail, the pointer is not released,
> which can lead to a memory leak bug. Fix this issue by adding
> nfp_nsp_close(nsp) in the error path.
>
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Fixes: f6e71efdf9fb1 ("nfp: abm: look up MAC addresses via management FW")
Acked-by: Jakub Kicinski <kuba@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nfp: abm: fix a memory leak bug
2020-05-02 22:42 [PATCH] nfp: abm: fix a memory leak bug wu000273
2020-05-04 17:01 ` Jakub Kicinski
@ 2020-05-04 19:05 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2020-05-04 19:05 UTC (permalink / raw)
To: wu000273; +Cc: kuba, oss-drivers, netdev, linux-kernel, kjlu
From: wu000273@umn.edu
Date: Sat, 2 May 2020 17:42:59 -0500
> From: Qiushi Wu <wu000273@umn.edu>
>
> In function nfp_abm_vnic_set_mac, pointer nsp is allocated by nfp_nsp_open.
> But when nfp_nsp_has_hwinfo_lookup fail, the pointer is not released,
> which can lead to a memory leak bug. Fix this issue by adding
> nfp_nsp_close(nsp) in the error path.
>
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nfp: abm: fix a memory leak bug
@ 2020-05-03 11:30 Markus Elfring
0 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2020-05-03 11:30 UTC (permalink / raw)
To: Qiushi Wu, netdev, oss-drivers
Cc: kernel-janitors, linux-kernel, David S. Miller, Jakub Kicinski,
Kangjie Lu
…
> Fix this issue by adding nfp_nsp_close(nsp) in the error path.
How do you think about a wording variant like the following?
Subject:
[PATCH v2] nfp: abm: Fix incomplete release of system resources in nfp_abm_vnic_set_mac()
Change description:
…
Thus add a call of the function “nfp_nsp_close” for the completion
of the exception handling.
…
> +++ b/drivers/net/ethernet/netronome/nfp/abm/main.c
> @@ -283,6 +283,7 @@ nfp_abm_vnic_set_mac(struct nfp_pf *pf, struct nfp_abm *abm, struct nfp_net *nn,
> if (!nfp_nsp_has_hwinfo_lookup(nsp)) {
> nfp_warn(pf->cpp, "NSP doesn't support PF MAC generation\n");
> eth_hw_addr_random(nn->dp.netdev);
> + nfp_nsp_close(nsp);
> return;
> }
I suggest to reconsider the order for resource clean-up function calls
a bit more.
+ nfp_nsp_close(nsp);
- eth_hw_addr_random(nn->dp.netdev);
- return;
+ goto generate_random_address;
Should such a jump target be added in another update step?
Would you like to add the tag “Fixes”?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-04 19:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 22:42 [PATCH] nfp: abm: fix a memory leak bug wu000273
2020-05-04 17:01 ` Jakub Kicinski
2020-05-04 19:05 ` David Miller
2020-05-03 11:30 Markus Elfring
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).