From: Joe Perches <joe@perches.com>
To: Chaehyun Lim <chaehyun.lim@gmail.com>
Cc: gregkh@linuxfoundation.org, johnny.kim@atmel.com,
rachel.kim@atmel.com, dean.lee@atmel.com, chris.park@atmel.com,
linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org
Subject: Re: [PATCH 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check
Date: Thu, 23 Jul 2015 10:19:41 -0700 [thread overview]
Message-ID: <1437671981.26573.13.camel@perches.com> (raw)
In-Reply-To: <1437650359-2051-2-git-send-email-chaehyun.lim@gmail.com>
On Thu, 2015-07-23 at 20:19 +0900, Chaehyun Lim wrote:
> Add error check if memory allocation is failed.
trivia:
> diff --git 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_ATOMIC);
> + if (pstrNetworkInfo == NULL)
> + return -ENOMEM;
> +
> WILC_memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo));
>
> pstrNetworkInfo->s8rssi = pu8WidVal[0];
> @@ -863,6 +866,9 @@ s32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo)
>
> if (u16IEsLen > 0) {
> pstrNetworkInfo->pu8IEs = kmalloc(u16IEsLen, GFP_ATOMIC);
> + if (pstrNetworkInfo->pu8IEs == NULL)
> + return -ENOMEM;
> +
> WILC_memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen);
>
> WILC_memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen);
> @@ -930,6 +936,9 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen,
> u16 u16IEsLen = 0;
>
> pstrConnectRespInfo = kmalloc(sizeof(tstrConnectRespInfo), GFP_ATOMIC);
> + if (pstrConnectRespInfo == NULL)
> + return -ENOMEM;
> +
> WILC_memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo));
>
> /* u16AssocRespLen = pu8Buffer[0]; */
These could use kzalloc
> @@ -950,6 +959,9 @@ s32 ParseAssocRespInfo(u8 *pu8Buffer, u32 u32BufferLen,
> u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN);
>
> pstrConnectRespInfo->pu8RespIEs = kmalloc(u16IEsLen, GFP_ATOMIC);
> + if (pstrConnectRespInfo->pu8RespIEs == NULL)
> + return -ENOMEM;
> +
> WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen);
>
> WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen);
And this one could use kmemdup
next prev parent reply other threads:[~2015-07-23 17:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 11:19 [PATCH 1/3] staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC Chaehyun Lim
2015-07-23 11:19 ` [PATCH 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check Chaehyun Lim
2015-07-23 11:31 ` Dan Carpenter
2015-07-23 17:19 ` Joe Perches [this message]
2015-07-23 11:19 ` [PATCH 3/3] staging: wilc1000: coreconfigurator.c: fix " Chaehyun Lim
2015-07-23 21:52 ` [PATCH 1/3] staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1437671981.26573.13.camel@perches.com \
--to=joe@perches.com \
--cc=chaehyun.lim@gmail.com \
--cc=chris.park@atmel.com \
--cc=dean.lee@atmel.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=johnny.kim@atmel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=rachel.kim@atmel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).