Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753437AbcJCQGn (ORCPT ); Mon, 3 Oct 2016 12:06:43 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:32791 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753329AbcJCQFk (ORCPT ); Mon, 3 Oct 2016 12:05:40 -0400 From: Sergio Paracuellos To: gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: wlang-ng: get memory from kernel allocators instead of big static buffer Date: Mon, 3 Oct 2016 18:05:44 +0200 Message-Id: <1475510744-12848-1-git-send-email-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1331 Lines: 46 This patch fix the following sparse warnings in prism2fw.c: warning: memset with byte count of 120000 Signed-off-by: Sergio Paracuellos --- drivers/staging/wlan-ng/prism2fw.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index 96aa211..7e33048 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -124,7 +124,7 @@ struct imgchunk { /* Data records */ static unsigned int ns3data; -static struct s3datarec s3data[S3DATA_MAX]; +static struct s3datarec *s3data; /* Plug records */ static unsigned int ns3plug; @@ -248,7 +248,12 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr, /* Initialize the data structures */ ns3data = 0; - memset(s3data, 0, sizeof(s3data)); + s3data = kcalloc(S3DATA_MAX, sizeof(*s3data), GFP_KERNEL); + if (unlikely(!s3data)) { + result = -ENOMEM; + goto out; + } + ns3plug = 0; memset(s3plug, 0, sizeof(s3plug)); ns3crc = 0; @@ -475,7 +480,7 @@ static void free_chunks(struct imgchunk *fchunk, unsigned int *nfchunks) static void free_srecs(void) { ns3data = 0; - memset(s3data, 0, sizeof(s3data)); + kfree(s3data); ns3plug = 0; memset(s3plug, 0, sizeof(s3plug)); ns3crc = 0; -- 1.9.1