linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next v4 0/3] some fix and cleanup for rtl8192e
@ 2021-12-02  3:07 Yang Yingliang
  2021-12-02  3:07 ` [PATCH -next v4 1/3] staging: rtl8192e: return error code from rtllib_softmac_init() Yang Yingliang
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Yang Yingliang @ 2021-12-02  3:07 UTC (permalink / raw)
  To: linux-kernel, linux-staging; +Cc: gregkh, paskripkin, dan.carpenter

v4: Fix crypt_info leak. Add fix tags for patch #1 and #2.
v3: Fix more leaks.  Break it up into multple patches.
v2: Make rtllib_softmac_init() return error codes.

patch #1, #2:
  fix error handle case in alloc_rtllib()

patch #3:
  remove unnecessary assignment

Yang Yingliang (3):
  staging: rtl8192e: return error code from rtllib_softmac_init()
  staging: rtl8192e: rtllib_module: fix error handle case in
    alloc_rtllib()
  staging: rtl8192e: rtllib_module: remove unnecessary assignment

 drivers/staging/rtl8192e/rtllib.h         |  2 +-
 drivers/staging/rtl8192e/rtllib_module.c  | 17 ++++++++++++-----
 drivers/staging/rtl8192e/rtllib_softmac.c |  6 ++++--
 3 files changed, 17 insertions(+), 8 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH -next v4 1/3] staging: rtl8192e: return error code from rtllib_softmac_init()
  2021-12-02  3:07 [PATCH -next v4 0/3] some fix and cleanup for rtl8192e Yang Yingliang
@ 2021-12-02  3:07 ` Yang Yingliang
  2021-12-02  3:07 ` [PATCH -next v4 2/3] staging: rtl8192e: rtllib_module: fix error handle case in alloc_rtllib() Yang Yingliang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yang Yingliang @ 2021-12-02  3:07 UTC (permalink / raw)
  To: linux-kernel, linux-staging; +Cc: gregkh, paskripkin, dan.carpenter

If it fails to allocate 'dot11d_info', rtllib_softmac_init()
should return error code. And remove unneccessary error message.

Fixes: 94a799425eee ("From: wlanfae <wlanfae@realtek.com>")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/staging/rtl8192e/rtllib.h         | 2 +-
 drivers/staging/rtl8192e/rtllib_softmac.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index c6f8b772335c..c985e4ebc545 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -1980,7 +1980,7 @@ void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
 void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee);
 
 void rtllib_start_ibss(struct rtllib_device *ieee);
-void rtllib_softmac_init(struct rtllib_device *ieee);
+int rtllib_softmac_init(struct rtllib_device *ieee);
 void rtllib_softmac_free(struct rtllib_device *ieee);
 void rtllib_disassociate(struct rtllib_device *ieee);
 void rtllib_stop_scan(struct rtllib_device *ieee);
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index aabbea48223d..4b6c2295a3cf 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -2952,7 +2952,7 @@ void rtllib_start_protocol(struct rtllib_device *ieee)
 	}
 }
 
-void rtllib_softmac_init(struct rtllib_device *ieee)
+int rtllib_softmac_init(struct rtllib_device *ieee)
 {
 	int i;
 
@@ -2963,7 +2963,8 @@ void rtllib_softmac_init(struct rtllib_device *ieee)
 		ieee->seq_ctrl[i] = 0;
 	ieee->dot11d_info = kzalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC);
 	if (!ieee->dot11d_info)
-		netdev_err(ieee->dev, "Can't alloc memory for DOT11D\n");
+		return -ENOMEM;
+
 	ieee->LinkDetectInfo.SlotIndex = 0;
 	ieee->LinkDetectInfo.SlotNum = 2;
 	ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0;
@@ -3029,6 +3030,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee)
 
 	tasklet_setup(&ieee->ps_task, rtllib_sta_ps);
 
+	return 0;
 }
 
 void rtllib_softmac_free(struct rtllib_device *ieee)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH -next v4 2/3] staging: rtl8192e: rtllib_module: fix error handle case in alloc_rtllib()
  2021-12-02  3:07 [PATCH -next v4 0/3] some fix and cleanup for rtl8192e Yang Yingliang
  2021-12-02  3:07 ` [PATCH -next v4 1/3] staging: rtl8192e: return error code from rtllib_softmac_init() Yang Yingliang
@ 2021-12-02  3:07 ` Yang Yingliang
  2021-12-02  3:07 ` [PATCH -next v4 3/3] staging: rtl8192e: rtllib_module: remove unnecessary assignment Yang Yingliang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yang Yingliang @ 2021-12-02  3:07 UTC (permalink / raw)
  To: linux-kernel, linux-staging; +Cc: gregkh, paskripkin, dan.carpenter

Some variables are leaked in the error handling in alloc_rtllib(), free
the variables in the error path.

Fixes: 94a799425eee ("From: wlanfae <wlanfae@realtek.com>")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/staging/rtl8192e/rtllib_module.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c
index 64d9feee1f39..f00ac94b2639 100644
--- a/drivers/staging/rtl8192e/rtllib_module.c
+++ b/drivers/staging/rtl8192e/rtllib_module.c
@@ -88,7 +88,7 @@ struct net_device *alloc_rtllib(int sizeof_priv)
 	err = rtllib_networks_allocate(ieee);
 	if (err) {
 		pr_err("Unable to allocate beacon storage: %d\n", err);
-		goto failed;
+		goto free_netdev;
 	}
 	rtllib_networks_initialize(ieee);
 
@@ -121,11 +121,13 @@ struct net_device *alloc_rtllib(int sizeof_priv)
 	ieee->hwsec_active = 0;
 
 	memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32);
-	rtllib_softmac_init(ieee);
+	err = rtllib_softmac_init(ieee);
+	if (err)
+		goto free_crypt_info;
 
 	ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL);
 	if (!ieee->pHTInfo)
-		return NULL;
+		goto free_softmac;
 
 	HTUpdateDefaultSetting(ieee);
 	HTInitializeHTInfo(ieee);
@@ -141,8 +143,14 @@ struct net_device *alloc_rtllib(int sizeof_priv)
 
 	return dev;
 
- failed:
+free_softmac:
+	rtllib_softmac_free(ieee);
+free_crypt_info:
+	lib80211_crypt_info_free(&ieee->crypt_info);
+	rtllib_networks_free(ieee);
+free_netdev:
 	free_netdev(dev);
+
 	return NULL;
 }
 EXPORT_SYMBOL(alloc_rtllib);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH -next v4 3/3] staging: rtl8192e: rtllib_module: remove unnecessary assignment
  2021-12-02  3:07 [PATCH -next v4 0/3] some fix and cleanup for rtl8192e Yang Yingliang
  2021-12-02  3:07 ` [PATCH -next v4 1/3] staging: rtl8192e: return error code from rtllib_softmac_init() Yang Yingliang
  2021-12-02  3:07 ` [PATCH -next v4 2/3] staging: rtl8192e: rtllib_module: fix error handle case in alloc_rtllib() Yang Yingliang
@ 2021-12-02  3:07 ` Yang Yingliang
  2021-12-02  5:38 ` [PATCH -next v4 0/3] some fix and cleanup for rtl8192e Dan Carpenter
  2021-12-02  8:38 ` Pavel Skripkin
  4 siblings, 0 replies; 6+ messages in thread
From: Yang Yingliang @ 2021-12-02  3:07 UTC (permalink / raw)
  To: linux-kernel, linux-staging; +Cc: gregkh, paskripkin, dan.carpenter

Remove the null pointer assignment after freeing 'ieee->pHTInfo'.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/staging/rtl8192e/rtllib_module.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c
index f00ac94b2639..41697ef55dbd 100644
--- a/drivers/staging/rtl8192e/rtllib_module.c
+++ b/drivers/staging/rtl8192e/rtllib_module.c
@@ -161,7 +161,6 @@ void free_rtllib(struct net_device *dev)
 				      netdev_priv_rsl(dev);
 
 	kfree(ieee->pHTInfo);
-	ieee->pHTInfo = NULL;
 	rtllib_softmac_free(ieee);
 
 	lib80211_crypt_info_free(&ieee->crypt_info);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH -next v4 0/3] some fix and cleanup for rtl8192e
  2021-12-02  3:07 [PATCH -next v4 0/3] some fix and cleanup for rtl8192e Yang Yingliang
                   ` (2 preceding siblings ...)
  2021-12-02  3:07 ` [PATCH -next v4 3/3] staging: rtl8192e: rtllib_module: remove unnecessary assignment Yang Yingliang
@ 2021-12-02  5:38 ` Dan Carpenter
  2021-12-02  8:38 ` Pavel Skripkin
  4 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2021-12-02  5:38 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, linux-staging, gregkh, paskripkin

On Thu, Dec 02, 2021 at 11:07:01AM +0800, Yang Yingliang wrote:
> v4: Fix crypt_info leak. Add fix tags for patch #1 and #2.
> v3: Fix more leaks.  Break it up into multple patches.
> v2: Make rtllib_softmac_init() return error codes.

Looks good!  Thanks.

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next v4 0/3] some fix and cleanup for rtl8192e
  2021-12-02  3:07 [PATCH -next v4 0/3] some fix and cleanup for rtl8192e Yang Yingliang
                   ` (3 preceding siblings ...)
  2021-12-02  5:38 ` [PATCH -next v4 0/3] some fix and cleanup for rtl8192e Dan Carpenter
@ 2021-12-02  8:38 ` Pavel Skripkin
  4 siblings, 0 replies; 6+ messages in thread
From: Pavel Skripkin @ 2021-12-02  8:38 UTC (permalink / raw)
  To: Yang Yingliang, linux-kernel, linux-staging; +Cc: gregkh, dan.carpenter

On 12/2/21 06:07, Yang Yingliang wrote:
> v4: Fix crypt_info leak. Add fix tags for patch #1 and #2.
> v3: Fix more leaks.  Break it up into multple patches.
> v2: Make rtllib_softmac_init() return error codes.
> 
> patch #1, #2:
>    fix error handle case in alloc_rtllib()
> 
> patch #3:
>    remove unnecessary assignment
> 
> Yang Yingliang (3):
>    staging: rtl8192e: return error code from rtllib_softmac_init()
>    staging: rtl8192e: rtllib_module: fix error handle case in
>      alloc_rtllib()
>    staging: rtl8192e: rtllib_module: remove unnecessary assignment
> 
>   drivers/staging/rtl8192e/rtllib.h         |  2 +-
>   drivers/staging/rtl8192e/rtllib_module.c  | 17 ++++++++++++-----
>   drivers/staging/rtl8192e/rtllib_softmac.c |  6 ++++--
>   3 files changed, 17 insertions(+), 8 deletions(-)
> 

Thank you!

Reviewed-by: Pavel Skripkin <paskripkin@gmail.com>



With regards,
Pavel Skripkin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-02  8:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02  3:07 [PATCH -next v4 0/3] some fix and cleanup for rtl8192e Yang Yingliang
2021-12-02  3:07 ` [PATCH -next v4 1/3] staging: rtl8192e: return error code from rtllib_softmac_init() Yang Yingliang
2021-12-02  3:07 ` [PATCH -next v4 2/3] staging: rtl8192e: rtllib_module: fix error handle case in alloc_rtllib() Yang Yingliang
2021-12-02  3:07 ` [PATCH -next v4 3/3] staging: rtl8192e: rtllib_module: remove unnecessary assignment Yang Yingliang
2021-12-02  5:38 ` [PATCH -next v4 0/3] some fix and cleanup for rtl8192e Dan Carpenter
2021-12-02  8:38 ` Pavel Skripkin

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).