* [RESEND V2 0/3] cover letter of wilc1000 patches
@ 2015-07-30 11:41 Chaehyun Lim
2015-07-30 11:41 ` [RESEND V2 1/3] staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC Chaehyun Lim
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Chaehyun Lim @ 2015-07-30 11:41 UTC (permalink / raw)
To: gregkh
Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
devel, Chaehyun Lim
Hi, Greg
I'm sorry that I did not say whether GFP_ATOMIC should be used or not.
This is my review on it. If it's not correct, please give me any comment or direction.
First patch has 4 sites of kmalloc change in coreconfigurator.c
First one, it is used for gps8ConfigPacket at CoreconfiguratorInit and CoreConfiguratorDeInit.
I think it should be removed next time because I cannot find anywhere to use it.
Then, it is okay to change flag as GFP_KERNEL.
Other three changes are used to handle host interface message within a kernel thread.
The manipulation of host interface message is not called on IRQ context and I could not
find any spin lock inside function.
If this patches are accepted, I will try to continue to change WILC_MALLOC macro as kmalloc.
I always appreciate your comment and advice.
Thanks
Chaehyun Lim
Chaehyun Lim (3):
staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC
staging: wilc1000: coreconfigurator.c: add kmalloc error check
staging: wilc1000: coreconfigurator.c: fix kmalloc error check
drivers/staging/wilc1000/coreconfigurator.c | 38 +++++++++++++++++------------
1 file changed, 23 insertions(+), 15 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RESEND V2 1/3] staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC
2015-07-30 11:41 [RESEND V2 0/3] cover letter of wilc1000 patches Chaehyun Lim
@ 2015-07-30 11:41 ` Chaehyun Lim
2015-07-30 11:41 ` [RESEND V2 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check Chaehyun Lim
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Chaehyun Lim @ 2015-07-30 11:41 UTC (permalink / raw)
To: gregkh
Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
devel, Chaehyun Lim
Use kmalloc and kmalloc_array instead of WILC_MALLOC.
Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
---
drivers/staging/wilc1000/coreconfigurator.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
index 342a336..37e09b8 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -674,7 +674,7 @@ s32 CoreConfiguratorInit(void)
sema_init(&SemHandleSendPkt, 1);
sema_init(&SemHandlePktResp, 0);
- gps8ConfigPacket = (s8 *)WILC_MALLOC(MAX_PACKET_BUFF_SIZE);
+ gps8ConfigPacket = kmalloc(MAX_PACKET_BUFF_SIZE, GFP_KERNEL);
if (gps8ConfigPacket == NULL) {
PRINT_ER("failed in gps8ConfigPacket allocation\n");
s32Error = WILC_NO_MEM;
@@ -811,7 +811,7 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo)
u32 u32Tsf_Lo;
u32 u32Tsf_Hi;
- pstrNetworkInfo = (tstrNetworkInfo *)WILC_MALLOC(sizeof(tstrNetworkInfo));
+ pstrNetworkInfo = kmalloc(sizeof(tstrNetworkInfo), GFP_KERNEL);
WILC_memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo));
pstrNetworkInfo->s8rssi = pu8WidVal[0];
@@ -861,7 +861,7 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo)
u16IEsLen = u16RxLen - (MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN);
if (u16IEsLen > 0) {
- pstrNetworkInfo->pu8IEs = (u8 *)WILC_MALLOC(u16IEsLen);
+ pstrNetworkInfo->pu8IEs = kmalloc(u16IEsLen, GFP_KERNEL);
WILC_memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen);
WILC_memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen);
@@ -928,7 +928,7 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen,
u8 *pu8IEs = 0;
u16 u16IEsLen = 0;
- pstrConnectRespInfo = (tstrConnectRespInfo *)WILC_MALLOC(sizeof(tstrConnectRespInfo));
+ pstrConnectRespInfo = kmalloc(sizeof(tstrConnectRespInfo), GFP_KERNEL);
WILC_memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo));
/* u16AssocRespLen = pu8Buffer[0]; */
@@ -948,7 +948,7 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen,
pu8IEs = &pu8Buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN];
u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN);
- pstrConnectRespInfo->pu8RespIEs = (u8 *)WILC_MALLOC(u16IEsLen);
+ pstrConnectRespInfo->pu8RespIEs = kmalloc(u16IEsLen, GFP_KERNEL);
WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen);
WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen);
@@ -1017,7 +1017,8 @@ s32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZ
}
}
- pstrSurveyResults = (wid_site_survey_reslts_s *)WILC_MALLOC(u32SurveyResultsCount * sizeof(wid_site_survey_reslts_s));
+ pstrSurveyResults = kmalloc_array(u32SurveyResultsCount,
+ sizeof(wid_site_survey_reslts_s), GFP_KERNEL);
if (pstrSurveyResults == NULL) {
u32SurveyResultsCount = 0;
WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RESEND V2 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check
2015-07-30 11:41 [RESEND V2 0/3] cover letter of wilc1000 patches Chaehyun Lim
2015-07-30 11:41 ` [RESEND V2 1/3] staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC Chaehyun Lim
@ 2015-07-30 11:41 ` Chaehyun Lim
2015-07-30 11:41 ` [RESEND V2 3/3] staging: wilc1000: coreconfigurator.c: fix " Chaehyun Lim
2015-07-30 12:03 ` [RESEND V2 0/3] cover letter of wilc1000 patches Chaehyun Lim
3 siblings, 0 replies; 6+ messages in thread
From: Chaehyun Lim @ 2015-07-30 11:41 UTC (permalink / raw)
To: gregkh
Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
devel, Chaehyun Lim
Add error check if memory allocation is failed.
Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
---
drivers/staging/wilc1000/coreconfigurator.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
index 37e09b8..67cec9d 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -812,6 +812,9 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo)
u32 u32Tsf_Hi;
pstrNetworkInfo = kmalloc(sizeof(tstrNetworkInfo), GFP_KERNEL);
+ if (!pstrNetworkInfo)
+ return -ENOMEM;
+
WILC_memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo));
pstrNetworkInfo->s8rssi = pu8WidVal[0];
@@ -862,6 +865,9 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo)
if (u16IEsLen > 0) {
pstrNetworkInfo->pu8IEs = kmalloc(u16IEsLen, GFP_KERNEL);
+ if (!pstrNetworkInfo->pu8IEs)
+ return -ENOMEM;
+
WILC_memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen);
WILC_memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen);
@@ -929,6 +935,9 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen,
u16 u16IEsLen = 0;
pstrConnectRespInfo = kmalloc(sizeof(tstrConnectRespInfo), GFP_KERNEL);
+ if (!pstrConnectRespInfo)
+ return -ENOMEM;
+
WILC_memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo));
/* u16AssocRespLen = pu8Buffer[0]; */
@@ -949,6 +958,9 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen,
u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN);
pstrConnectRespInfo->pu8RespIEs = kmalloc(u16IEsLen, GFP_KERNEL);
+ if (!pstrConnectRespInfo->pu8RespIEs)
+ return -ENOMEM;
+
WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen);
WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen);
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [RESEND V2 3/3] staging: wilc1000: coreconfigurator.c: fix kmalloc error check
2015-07-30 11:41 [RESEND V2 0/3] cover letter of wilc1000 patches Chaehyun Lim
2015-07-30 11:41 ` [RESEND V2 1/3] staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC Chaehyun Lim
2015-07-30 11:41 ` [RESEND V2 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check Chaehyun Lim
@ 2015-07-30 11:41 ` Chaehyun Lim
2015-07-30 12:03 ` [RESEND V2 0/3] cover letter of wilc1000 patches Chaehyun Lim
3 siblings, 0 replies; 6+ messages in thread
From: Chaehyun Lim @ 2015-07-30 11:41 UTC (permalink / raw)
To: gregkh
Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
devel, Chaehyun Lim
Return -ENOMEM if memory allocation is failed.
Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
---
drivers/staging/wilc1000/coreconfigurator.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
index 67cec9d..258a0d2 100644
--- a/drivers/staging/wilc1000/coreconfigurator.c
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -675,11 +675,8 @@ s32 CoreConfiguratorInit(void)
sema_init(&SemHandlePktResp, 0);
gps8ConfigPacket = kmalloc(MAX_PACKET_BUFF_SIZE, GFP_KERNEL);
- if (gps8ConfigPacket == NULL) {
- PRINT_ER("failed in gps8ConfigPacket allocation\n");
- s32Error = WILC_NO_MEM;
- goto _fail_;
- }
+ if (!gps8ConfigPacket)
+ return -ENOMEM;
WILC_memset((void *)gps8ConfigPacket, 0, MAX_PACKET_BUFF_SIZE);
@@ -1031,10 +1028,8 @@ s32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZ
pstrSurveyResults = kmalloc_array(u32SurveyResultsCount,
sizeof(wid_site_survey_reslts_s), GFP_KERNEL);
- if (pstrSurveyResults == NULL) {
- u32SurveyResultsCount = 0;
- WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
- }
+ if (!pstrSurveyResults)
+ return -ENOMEM;
WILC_memset((void *)(pstrSurveyResults), 0, u32SurveyResultsCount * sizeof(wid_site_survey_reslts_s));
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RESEND V2 0/3] cover letter of wilc1000 patches
2015-07-30 11:41 [RESEND V2 0/3] cover letter of wilc1000 patches Chaehyun Lim
` (2 preceding siblings ...)
2015-07-30 11:41 ` [RESEND V2 3/3] staging: wilc1000: coreconfigurator.c: fix " Chaehyun Lim
@ 2015-07-30 12:03 ` Chaehyun Lim
2015-07-30 12:18 ` Dan Carpenter
3 siblings, 1 reply; 6+ messages in thread
From: Chaehyun Lim @ 2015-07-30 12:03 UTC (permalink / raw)
To: Greg KH
Cc: johnny.kim, rachel.kim, dean.lee, chris.park, linux-wireless,
devel, Chaehyun Lim
I'm sorry that I have mistake the number of kmalloc changes. The total
change is 6, not 4.
On Thu, Jul 30, 2015 at 8:41 PM, Chaehyun Lim <chaehyun.lim@gmail.com> wrote:
> Hi, Greg
>
> I'm sorry that I did not say whether GFP_ATOMIC should be used or not.
> This is my review on it. If it's not correct, please give me any comment or direction.
>
> First patch has 4 sites of kmalloc change in coreconfigurator.c
> First one, it is used for gps8ConfigPacket at CoreconfiguratorInit and CoreConfiguratorDeInit.
> I think it should be removed next time because I cannot find anywhere to use it.
> Then, it is okay to change flag as GFP_KERNEL.
>
> Other three changes are used to handle host interface message within a kernel thread.
> The manipulation of host interface message is not called on IRQ context and I could not
> find any spin lock inside function.
>
> If this patches are accepted, I will try to continue to change WILC_MALLOC macro as kmalloc.
> I always appreciate your comment and advice.
>
> Thanks
> Chaehyun Lim
>
>
> Chaehyun Lim (3):
> staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC
> staging: wilc1000: coreconfigurator.c: add kmalloc error check
> staging: wilc1000: coreconfigurator.c: fix kmalloc error check
>
> drivers/staging/wilc1000/coreconfigurator.c | 38 +++++++++++++++++------------
> 1 file changed, 23 insertions(+), 15 deletions(-)
>
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND V2 0/3] cover letter of wilc1000 patches
2015-07-30 12:03 ` [RESEND V2 0/3] cover letter of wilc1000 patches Chaehyun Lim
@ 2015-07-30 12:18 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2015-07-30 12:18 UTC (permalink / raw)
To: Chaehyun Lim
Cc: Greg KH, rachel.kim, dean.lee, chris.park, devel, linux-wireless,
johnny.kim
On Thu, Jul 30, 2015 at 09:03:48PM +0900, Chaehyun Lim wrote:
> On Thu, Jul 30, 2015 at 8:41 PM, Chaehyun Lim <chaehyun.lim@gmail.com> wrote:
> >
> > First patch has 4 sites of kmalloc change in coreconfigurator.c
> > First one, it is used for gps8ConfigPacket at CoreconfiguratorInit and CoreConfiguratorDeInit.
> > I think it should be removed next time because I cannot find anywhere to use it.
> > Then, it is okay to change flag as GFP_KERNEL.
> >
> > Other three changes are used to handle host interface message within a kernel thread.
> > The manipulation of host interface message is not called on IRQ context and I could not
> > find any spin lock inside function.
> >
This information is good information and it should be in the patch
description.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-07-30 12:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-30 11:41 [RESEND V2 0/3] cover letter of wilc1000 patches Chaehyun Lim
2015-07-30 11:41 ` [RESEND V2 1/3] staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC Chaehyun Lim
2015-07-30 11:41 ` [RESEND V2 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check Chaehyun Lim
2015-07-30 11:41 ` [RESEND V2 3/3] staging: wilc1000: coreconfigurator.c: fix " Chaehyun Lim
2015-07-30 12:03 ` [RESEND V2 0/3] cover letter of wilc1000 patches Chaehyun Lim
2015-07-30 12:18 ` Dan Carpenter
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).