lkml.org 
[lkml]   [2022]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] staging: r8188eu: change the allocation type of pdata_attr
Date
From: Xiaoke Wang <xkernel.wang@foxmail.com>

`pdata_attr` was allocated by kzalloc() in go_add_group_info_attr(), but
there is a lack of error handlers along the call chain it lies and the
lifetime of `pdata_attr` is only in go_add_group_info_attr().
Therefore, changing it to a local variable on stack like the other
functions in rtw_p2p.c is a possible choice, such as
`u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 };` in build_probe_resp_p2p_ie()
which is the caller of go_add_group_info_attr().

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
drivers/staging/r8188eu/core/rtw_p2p.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c
index e2b6cf2..f1a5df8 100644
--- a/drivers/staging/r8188eu/core/rtw_p2p.c
+++ b/drivers/staging/r8188eu/core/rtw_p2p.c
@@ -27,15 +27,14 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf)
struct list_head *phead, *plist;
u32 len = 0;
u16 attr_len = 0;
- u8 tmplen, *pdata_attr, *pstart, *pcur;
+ u8 pdata_attr[MAX_P2P_IE_LEN] = { 0x00 };
+ u8 tmplen, *pstart, *pcur;
struct sta_info *psta = NULL;
struct adapter *padapter = pwdinfo->padapter;
struct sta_priv *pstapriv = &padapter->stapriv;

DBG_88E("%s\n", __func__);

- pdata_attr = kzalloc(MAX_P2P_IE_LEN, GFP_KERNEL);
-
pstart = pdata_attr;
pcur = pdata_attr;

@@ -106,7 +105,6 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf)
if (attr_len > 0)
len = rtw_set_p2p_attr_content(pbuf, P2P_ATTR_GROUP_INFO, attr_len, pdata_attr);

- kfree(pdata_attr);
return len;
}

--
\
 
 \ /
  Last update: 2022-03-31 09:38    [W:0.042 / U:1.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site