Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] brcmsmac: fix potential memory leak in wlc_phy_attach_lcnphy
@ 2020-09-07 16:22 Keita Suzuki
2020-09-07 20:46 ` Arend Van Spriel
0 siblings, 1 reply; 8+ messages in thread
From: Keita Suzuki @ 2020-09-07 16:22 UTC (permalink / raw)
Cc: keitasuzuki.park, takafumi, Arend van Spriel, Franky Lin,
Hante Meuleman, Chi-Hsien Lin, Wright Feng, Kalle Valo,
David S. Miller, Jakub Kicinski,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:NETWORKING DRIVERS, open list
When wlc_phy_txpwr_srom_read_lcnphy fails in wlc_phy_attach_lcnphy,
the allocated pi->u.pi_lcnphy is leaked, since struct brcms_phy will be
freed in the caller function.
Fix this by calling wlc_phy_detach_lcnphy in the error handler of
wlc_phy_txpwr_srom_read_lcnphy before returning.
Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
---
.../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
index 7ef36234a25d..6d70f51b2ddf 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
@@ -5065,8 +5065,10 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi)
pi->pi_fptr.radioloftget = wlc_lcnphy_get_radio_loft;
pi->pi_fptr.detach = wlc_phy_detach_lcnphy;
- if (!wlc_phy_txpwr_srom_read_lcnphy(pi))
+ if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) {
+ wlc_phy_detach_lcnphy(pi);
return false;
+ }
if (LCNREV_IS(pi->pubpi.phy_rev, 1)) {
if (pi_lcn->lcnphy_tempsense_option == 3) {
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] brcmsmac: fix potential memory leak in wlc_phy_attach_lcnphy
2020-09-07 16:22 [PATCH] brcmsmac: fix potential memory leak in wlc_phy_attach_lcnphy Keita Suzuki
@ 2020-09-07 20:46 ` Arend Van Spriel
2020-09-08 0:13 ` [PATCH] brcmsmac: fix " Keita Suzuki
0 siblings, 1 reply; 8+ messages in thread
From: Arend Van Spriel @ 2020-09-07 20:46 UTC (permalink / raw)
To: Keita Suzuki
Cc: takafumi, Franky Lin, Hante Meuleman, Chi-Hsien Lin, Wright Feng,
Kalle Valo, David S. Miller, Jakub Kicinski,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:NETWORKING DRIVERS, open list
On 9/7/2020 6:22 PM, Keita Suzuki wrote:
> When wlc_phy_txpwr_srom_read_lcnphy fails in wlc_phy_attach_lcnphy,
> the allocated pi->u.pi_lcnphy is leaked, since struct brcms_phy will be
> freed in the caller function.
>
> Fix this by calling wlc_phy_detach_lcnphy in the error handler of
> wlc_phy_txpwr_srom_read_lcnphy before returning.
>
> Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
> ---
> .../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
> index 7ef36234a25d..6d70f51b2ddf 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
> @@ -5065,8 +5065,10 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi)
> pi->pi_fptr.radioloftget = wlc_lcnphy_get_radio_loft;
> pi->pi_fptr.detach = wlc_phy_detach_lcnphy;
>
> - if (!wlc_phy_txpwr_srom_read_lcnphy(pi))
> + if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) {
> + wlc_phy_detach_lcnphy(pi);
Essentially the same but I prefer to simply do the kfree() call directly
here as we also allocate in this function.
Thanks,
Arend
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] brcmsmac: fix memory leak in wlc_phy_attach_lcnphy
2020-09-07 20:46 ` Arend Van Spriel
@ 2020-09-08 0:13 ` Keita Suzuki
2020-09-08 11:18 ` Arend Van Spriel
0 siblings, 1 reply; 8+ messages in thread
From: Keita Suzuki @ 2020-09-08 0:13 UTC (permalink / raw)
Cc: keitasuzuki.park, takafumi, Arend van Spriel, Franky Lin,
Hante Meuleman, Chi-Hsien Lin, Wright Feng, Kalle Valo,
David S. Miller, Jakub Kicinski,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:NETWORKING DRIVERS, open list
When wlc_phy_txpwr_srom_read_lcnphy fails in wlc_phy_attach_lcnphy,
the allocated pi->u.pi_lcnphy is leaked, since struct brcms_phy will be
freed in the caller function.
Fix this by calling wlc_phy_detach_lcnphy in the error handler of
wlc_phy_txpwr_srom_read_lcnphy before returning.
Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
---
.../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
index 7ef36234a25d..66797dc5e90d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
@@ -5065,8 +5065,10 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi)
pi->pi_fptr.radioloftget = wlc_lcnphy_get_radio_loft;
pi->pi_fptr.detach = wlc_phy_detach_lcnphy;
- if (!wlc_phy_txpwr_srom_read_lcnphy(pi))
+ if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) {
+ kfree(pi->u.pi_lcnphy);
return false;
+ }
if (LCNREV_IS(pi->pubpi.phy_rev, 1)) {
if (pi_lcn->lcnphy_tempsense_option == 3) {
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] brcmsmac: fix memory leak in wlc_phy_attach_lcnphy
2020-09-08 0:13 ` [PATCH] brcmsmac: fix " Keita Suzuki
@ 2020-09-08 11:18 ` Arend Van Spriel
2020-09-08 12:02 ` Keita Suzuki
0 siblings, 1 reply; 8+ messages in thread
From: Arend Van Spriel @ 2020-09-08 11:18 UTC (permalink / raw)
To: Keita Suzuki
Cc: takafumi, Franky Lin, Hante Meuleman, Chi-Hsien Lin, Wright Feng,
Kalle Valo, David S. Miller, Jakub Kicinski,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:NETWORKING DRIVERS, open list
On 9/8/2020 2:13 AM, Keita Suzuki wrote:
> When wlc_phy_txpwr_srom_read_lcnphy fails in wlc_phy_attach_lcnphy,
> the allocated pi->u.pi_lcnphy is leaked, since struct brcms_phy will be
> freed in the caller function.
>
> Fix this by calling wlc_phy_detach_lcnphy in the error handler of
> wlc_phy_txpwr_srom_read_lcnphy before returning.
Thanks for resubmitting the patch addressing my comment. For clarity it
is recommended to mark the subject with '[PATCH V2]' and add a ...
> Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
> ---
... changelog here describing difference between previous patch and this
version.
Regards,
Arend
---
> .../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] brcmsmac: fix memory leak in wlc_phy_attach_lcnphy
2020-09-08 11:18 ` Arend Van Spriel
@ 2020-09-08 12:02 ` Keita Suzuki
2020-09-08 12:12 ` Arend Van Spriel
0 siblings, 1 reply; 8+ messages in thread
From: Keita Suzuki @ 2020-09-08 12:02 UTC (permalink / raw)
To: Arend Van Spriel
Cc: Takafumi Kubota, Franky Lin, Hante Meuleman, Chi-Hsien Lin,
Wright Feng, Kalle Valo, David S. Miller, Jakub Kicinski,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:NETWORKING DRIVERS, open list
Thank you for your comment. I am relatively new to the Linux
kernel community, so I am more than happy to receive comments.
Please let me know if I'm violating any other rules.
> > Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
> > ---
> ... changelog here describing difference between previous patch and this
> version.
I will re-send the patch with the change log.
Thanks,
Keita
2020年9月8日(火) 20:18 Arend Van Spriel <arend.vanspriel@broadcom.com>:
>
> On 9/8/2020 2:13 AM, Keita Suzuki wrote:
> > When wlc_phy_txpwr_srom_read_lcnphy fails in wlc_phy_attach_lcnphy,
> > the allocated pi->u.pi_lcnphy is leaked, since struct brcms_phy will be
> > freed in the caller function.
> >
> > Fix this by calling wlc_phy_detach_lcnphy in the error handler of
> > wlc_phy_txpwr_srom_read_lcnphy before returning.
>
> Thanks for resubmitting the patch addressing my comment. For clarity it
> is recommended to mark the subject with '[PATCH V2]' and add a ...
>
> > Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
> > ---
> ... changelog here describing difference between previous patch and this
> version.
>
> Regards,
> Arend
> ---
> > .../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] brcmsmac: fix memory leak in wlc_phy_attach_lcnphy
2020-09-08 12:02 ` Keita Suzuki
@ 2020-09-08 12:12 ` Arend Van Spriel
2020-09-08 12:17 ` [PATCH v2] " Keita Suzuki
0 siblings, 1 reply; 8+ messages in thread
From: Arend Van Spriel @ 2020-09-08 12:12 UTC (permalink / raw)
To: Keita Suzuki
Cc: Takafumi Kubota, Franky Lin, Hante Meuleman, Chi-Hsien Lin,
Wright Feng, Kalle Valo, David S. Miller, Jakub Kicinski,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
open list:NETWORKING DRIVERS, open list
On 9/8/2020 2:02 PM, Keita Suzuki wrote:
> Thank you for your comment. I am relatively new to the Linux
> kernel community, so I am more than happy to receive comments.
> Please let me know if I'm violating any other rules.
Sure ;-)
Here a useful link that Kalle (wireless drivers maintainer) is always
sharing in his email signature:
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Regards,
Arend
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] brcmsmac: fix memory leak in wlc_phy_attach_lcnphy
2020-09-08 12:12 ` Arend Van Spriel
@ 2020-09-08 12:17 ` Keita Suzuki
2020-09-09 7:32 ` Kalle Valo
0 siblings, 1 reply; 8+ messages in thread
From: Keita Suzuki @ 2020-09-08 12:17 UTC (permalink / raw)
Cc: keitasuzuki.park, takafumi, Arend van Spriel, Franky Lin,
Hante Meuleman, Chi-Hsien Lin, Wright Feng, Kalle Valo,
David S. Miller, Jakub Kicinski, linux-wireless,
brcm80211-dev-list.pdl, brcm80211-dev-list, netdev, linux-kernel
When wlc_phy_txpwr_srom_read_lcnphy fails in wlc_phy_attach_lcnphy,
the allocated pi->u.pi_lcnphy is leaked, since struct brcms_phy will be
freed in the caller function.
Fix this by calling wlc_phy_detach_lcnphy in the error handler of
wlc_phy_txpwr_srom_read_lcnphy before returning.
Signed-off-by: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
---
changelog(v2): change call from wlc_phy_detach_lcnphy() to kfree()
.../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
index 7ef36234a25d..66797dc5e90d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
@@ -5065,8 +5065,10 @@ bool wlc_phy_attach_lcnphy(struct brcms_phy *pi)
pi->pi_fptr.radioloftget = wlc_lcnphy_get_radio_loft;
pi->pi_fptr.detach = wlc_phy_detach_lcnphy;
- if (!wlc_phy_txpwr_srom_read_lcnphy(pi))
+ if (!wlc_phy_txpwr_srom_read_lcnphy(pi)) {
+ kfree(pi->u.pi_lcnphy);
return false;
+ }
if (LCNREV_IS(pi->pubpi.phy_rev, 1)) {
if (pi_lcn->lcnphy_tempsense_option == 3) {
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-09-09 7:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 16:22 [PATCH] brcmsmac: fix potential memory leak in wlc_phy_attach_lcnphy Keita Suzuki
2020-09-07 20:46 ` Arend Van Spriel
2020-09-08 0:13 ` [PATCH] brcmsmac: fix " Keita Suzuki
2020-09-08 11:18 ` Arend Van Spriel
2020-09-08 12:02 ` Keita Suzuki
2020-09-08 12:12 ` Arend Van Spriel
2020-09-08 12:17 ` [PATCH v2] " Keita Suzuki
2020-09-09 7:32 ` Kalle Valo
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).