linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chaehyun Lim <chaehyun.lim@gmail.com>
To: gregkh@linuxfoundation.org
Cc: 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, Chaehyun Lim <chaehyun.lim@gmail.com>
Subject: [PATCH V3 3/3] staging: wilc1000: coreconfigurator.c: fix kmalloc error check
Date: Fri, 24 Jul 2015 08:55:55 +0900	[thread overview]
Message-ID: <1437695755-9731-3-git-send-email-chaehyun.lim@gmail.com> (raw)
In-Reply-To: <1437695755-9731-1-git-send-email-chaehyun.lim@gmail.com>

Return -ENOMEM if memory allocation is failed.

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
---
V2: Use ! operator instead of NULL comparison
V3: this patch is rebased by previous modification

 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 0ff9705..b2abd8b 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);
 
@@ -1032,10 +1029,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


  parent reply	other threads:[~2015-07-23 23:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23 23:55 [PATCH V2 1/3] staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC Chaehyun Lim
2015-07-23 23:55 ` [PATCH V3 2/3] staging: wilc1000: coreconfigurator.c: add kmalloc error check Chaehyun Lim
2015-07-23 23:55 ` Chaehyun Lim [this message]
2015-07-24  0:44 ` [PATCH V2 1/3] staging: wilc1000: coreconfigurator.c: remove WILC_MALLOC Dan Carpenter
     [not found]   ` <55B59D8D.6010805@atmel.com>
2015-07-27  7:52     ` Dan Carpenter
2015-07-29 20:45 ` 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=1437695755-9731-3-git-send-email-chaehyun.lim@gmail.com \
    --to=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).