From patchwork Thu Aug 4 18:13:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 12936559 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1EFBC19F2A for ; Thu, 4 Aug 2022 18:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239889AbiHDSNr (ORCPT ); Thu, 4 Aug 2022 14:13:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232643AbiHDSNp (ORCPT ); Thu, 4 Aug 2022 14:13:45 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55EB751A0E for ; Thu, 4 Aug 2022 11:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1659636824; x=1691172824; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=r6XJ0SeY6rxCDySXDY40Q1mXMhU3k9jnDRpXHUTtN+E=; b=xAQ+1Zm6tF2RMryAKXAF6n2fgPSutS88EBfDKSDKJV9vCyBOINtDP9aY keE0FNyCK8fnZq7fvmRiiplzAPOWW0m8NvB1LoK3/r5572Seqj2+vcx+y UcVjEnWrTvSblqCa/NqKuKcWKrtHuQzpIU+jBMqMCHLW87CcA0M/RF209 OTu/R8zRlO8SEbzAD9/IKzkSXyrwLpmhTgHqA72e+d++sDe1v8vsveNt6 CsnzrB2NQqY8Ss5JdMh+206w7rgOE9wCMfLnC7ovBoiXqSIYW0o9deQ8Z /zVnGzrNszKI9lEB0XGvdBcb2tgjjmmgiuh+hvjHJknKhh8iIqAkx634U A==; X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="185153282" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 04 Aug 2022 11:13:43 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 4 Aug 2022 11:13:43 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17 via Frontend Transport; Thu, 4 Aug 2022 11:13:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AFYRhLrFfNXST2ujcEUpn+0H6t+UtxEdESy0jXK4s8D/Ak8ghTDFUH2ZUFB/qICDLnE4q70TO5URcya4WzVEXIOA0X6ZIg7IrgPxlZnvPm74YEe6BoPuMZhbCfxEuYmuw7LH4l6VpzWpQiy2lVwKBj9wQoa2Wb4IkhDS7ONFNHW+fQEgxbCGRDu7fxlCn/jd38pzoiuxtj3pdQmB+1IyzoaYyYWrkWRBhsqop5MPjK9CEzMdqHD0GaJO+FPnICSD9JzmnYDjrKQmhDkCeAvtIW8qzhHr/iuLhy/LSNo0vhYv5F6AbACdd3PrTgLB/BF7peohKrDqyBLdEQT/ue5lzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M8vKX4bKf4Xn79o0+G+M/R6eq68flbGtKlrQm1FVjN8=; b=Gcz3eXuFNJBbFb8maEoeBqhG4QuVnfklqdO+EI8O44B1/iDGu8ppgClu1pxKrYumxX3tapkriGnP1uPdcNCJktjO6umyqhSOZWSWowdIufy7Bk+3KtchaDmIALY/8DApZBZRv1ITWrSuLQKBMf+ja+OSDkKQj0vyDlzxh8nzAc1jmNvu9SY+W6WQIldSt/WbT6fg9Xc3MiFz4dSVUHAV/WeaHt3mqgwC3Ml2jaEEIovEkZ2jfFOUvnB8fHtCTGIFtrEs8wlCBR7grTKsIQ2Xf/O7zFFD9QPSVxic4QWm5S+vAdiEv1LYikPCOP/TA0f+qlfWCiB5ja/7Lx0g0/2dVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M8vKX4bKf4Xn79o0+G+M/R6eq68flbGtKlrQm1FVjN8=; b=W9bBZnXfj454SxzSyG1DyjbKFHQasLqS0D35ksmos0b6ShSZsNVVVVE4C+iJWWvEr/dRTK1SaYfEJZVk/mLdoztoVJTXrp8oH1RVuv4XpW9oWj5Q3ycH9x/HEptsIMVLlrC7k31HL1gJc8HpMEg5+LQAvVQXCIslSJRe3oVRwBo= Received: from PH0PR11MB5176.namprd11.prod.outlook.com (2603:10b6:510:3f::5) by SA2PR11MB5211.namprd11.prod.outlook.com (2603:10b6:806:fb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Thu, 4 Aug 2022 18:13:42 +0000 Received: from PH0PR11MB5176.namprd11.prod.outlook.com ([fe80::8d74:5951:571e:531e]) by PH0PR11MB5176.namprd11.prod.outlook.com ([fe80::8d74:5951:571e:531e%9]) with mapi id 15.20.5504.015; Thu, 4 Aug 2022 18:13:42 +0000 From: To: CC: , , , Subject: [PATCH v2] wifi: wilc1000: fix DMA on stack objects Thread-Topic: [PATCH v2] wifi: wilc1000: fix DMA on stack objects Thread-Index: AQHYqC3tsnzfAAD+gEWLNR85ROYhfw== Date: Thu, 4 Aug 2022 18:13:42 +0000 Message-ID: <20220804181340.365429-1-ajay.kathat@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.34.1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microchip.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8d843c9d-dfff-4e4f-7992-08da7645100f x-ms-traffictypediagnostic: SA2PR11MB5211:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: e69t3laD3zdJ/96CQh/6DHwyyLYxQF8X1UfabvyOYcaqL6iaN9JPhhQP+FYGjKaprROta7wkSquIb6OhwtfphyjRnAyReNbav34LYJhHXmol/z9srP1FiGyVVQ6bULnq5OAtla9qei7pZhj8JaukIVEI0bHwM+0agIrdr6O/WBFhZWsAC17a85gB9CeSbKNWy7tJ+q7yTLQceOIyansfJXXqgWWXW9+JqfiRC9imD2Ecno0JkFwinxm5plwI9pp66SEXDbDxFmrhtcUQon6+EbECuwRufwIo4zVCbAYImhZp3Ag3KwcuGszeOlIfopUiXC2f3kAKfsuDqT/JlhQdfB52PLT6cgv2mr/LUrSmknsb/JjAnb+LbB3vFrc6gpTUxDwUYHR/oBQLxJ2fj1umDLN+TVyuA3ASemqFPzyqNrCaCllKUub189GnImSvhp3NFdXll8xnkC+uQYQilI9v1fhqFm17MIw+lm3TqmWn+H7PteC/2PNPqzIE2aJfJ/sUoy8t7q4ty/Cl/Ks3vYvdOCVmr7h4lpePntnNL/eqMkeueYK8y6JIeZReHt0Xmq4dIepA4B2ks2IFZUoYG2dHvMyBuSeLbTQfzqQ0P+sTLOVZcjxyAMm/vwVjOOGqh5jzRZijWKmkOXt28Tl3uNGtmvTtpV01QBS1egj8W4QetvxB+2LDjm+1+BBMA0KaYNhom5lhBtV/II3wVAjQiXTz4PvYHzoRGQzDRLmAIg70pHlVGRFASkGhL1GwZRMsRxX5txyM3XwJ/VorQw7AdXeyQO91VgR1gll7C47RooSCqaCKtvzWKJ7vYtrariD8+tUdu3bufgDpGmwHt5x+GmuNTg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR11MB5176.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(366004)(136003)(39860400002)(346002)(376002)(396003)(6916009)(36756003)(41300700001)(4326008)(66446008)(91956017)(8676002)(54906003)(66476007)(66556008)(66946007)(76116006)(64756008)(71200400001)(966005)(478600001)(86362001)(6486002)(26005)(55236004)(6506007)(8936002)(6512007)(5660300002)(1076003)(107886003)(2616005)(83380400001)(186003)(38100700002)(2906002)(316002)(122000001)(38070700005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?W/M/ikl+A+vPrIrQAIkttEK?= =?iso-8859-1?q?2ENYxUy4beTIFVJyTWkI12QJhj1wqIRBcPNQuo79e6ArjsWuUg4ufNQp7vlr?= =?iso-8859-1?q?WXq+bm5COr+pIWuctAJntLfnU7N6Cc+rwuGtoLvrdShRNPexE+HTsbg6lqLP?= =?iso-8859-1?q?AXUPmmctYMpoDyC1g1fKjQ6X9NBphjQUpFn5eVuGiygEFyGjxJBfhNcRM0PO?= =?iso-8859-1?q?ytagjD30Njmgu0Y+FU9W273TvqJr6D560P3lx389VscpH5Wk+CAYzIP3gecg?= =?iso-8859-1?q?s1vIHUoHV2h/yd2EyA1raMKbMe7yBEIjITyRGCK9VZD26aTxcUH9oJidldeq?= =?iso-8859-1?q?24M69sP8sWZUyb4QtjvELMw6e/I0Gp54FK+RwxRKSeAMNc26eXu4nr/OjD99?= =?iso-8859-1?q?EqE/a+CwtAvHHVIp0ufVfYEkYZksMEpb3XfX0LMr5fj0jvQo5ZH4QlsnqAbE?= =?iso-8859-1?q?PvgO/zUiBg2hTHWEBGQm8toLm/ayTfDGezgTCKtHPvf8VSKedghngF/9tI31?= =?iso-8859-1?q?++BFbzpks7aKTgIuPYNMEUzff2mtEATbSeq5TWll1h/D09nNGG1PYTcKSB5L?= =?iso-8859-1?q?RXYMks7sNR9dg8s41xxwqftSdCs+koIEURUjM6/lHXmfQ9afcQq7ZGmsJrD5?= =?iso-8859-1?q?5xm/bDwc74nkzxG+s7BN6qTNKpXOmwjVl/vnQEFjHebB+Q/yUNIbo0L9YgP5?= =?iso-8859-1?q?fDJapYbI4rnBHAwG7ompim1c1+XfP4ssNo/BOJ3vX/xwX5rJ+3caA8eQgN/E?= =?iso-8859-1?q?2i9LmJOrs2tkM3GxBQHm9XpMr3aJDEfk4++52MO2zwG54+5/+lFUhhaHat20?= =?iso-8859-1?q?GznJuwefZR37V8zLX2f6zGXWX3fFNBnd9yVewEN9YvKOJ0SBVb1nudb9KA6c?= =?iso-8859-1?q?NYIutmUj5hzDH/BQuYXnfctgaOXd/qTc34b37APWTzb51ntTfdDN9ROLyPVO?= =?iso-8859-1?q?LH+HaPO8aLydxx3eyRhLDhyjSdS8dA8llrhyptTY9sNI2fyWxdpfXL96/rF5?= =?iso-8859-1?q?dT3g6Y1M99tQpRWLrCMvZVXgSLzRrQ9dVBfVEIYTZ85Dk5kiWwzDqZrWL1XW?= =?iso-8859-1?q?y4oV3MGH0W9hXBnzrxgpNBTM2wtdUpxVAkwcvbRyfiR6Vegce7XRXUZbyo+y?= =?iso-8859-1?q?DgXUyuLK1eKpJP/F0jtH82PcGpWnVZdziuigL6XTWv/5+7+cxwXD6a+PoE8a?= =?iso-8859-1?q?tT2bzUtV+jKgDlna8cP+/kjKQNex9W3rv77qS2PeHQ7e0TjSidhxJu5xeF8r?= =?iso-8859-1?q?rrEIo3R7WhL15xR/tSR2iMIyMW++3QU3iySmO1rAs7fxxCillZhph01u45eM?= =?iso-8859-1?q?lBCojJTkAiaU+UuG5Zo/YfF0IPiXraAf26duTiOHi8t0vH/pzdU1Iv4VQ1ZR?= =?iso-8859-1?q?RIceUTxUInW+9PoBLq2l2EZKNnkw3ta2VTIP/NYAx6vLZeaItMhDD3Mppb/k?= =?iso-8859-1?q?0IeAdreNhQFbporZV6hOTQU733v142lgfbvpojtJEm2N0YVmI9udDShS+7jF?= =?iso-8859-1?q?6fkNeJMBmJ6dyJuSixUZ3ggN6YyPN/iGIypLHCwPMjnvaI2h1NpuQht/hH1z?= =?iso-8859-1?q?oGUSBXp9joyjOUit8vxVqtg439YRR8cWkVOPDLnnIjVO3Tiu+K6priIQrMN7?= =?iso-8859-1?q?nbfLQW0XIzJQkZ1Au5kO7n1s2ZcOIA6UV4z5FKA=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5176.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d843c9d-dfff-4e4f-7992-08da7645100f X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Aug 2022 18:13:42.0460 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jXwf6yoSANhcWE7wUUslmIo1jwEdieQNfJuTHSfCptaByAfH6mk2BZ/C0aEqEwLAvoRNmbyCwPrQ3ghcIkYtEct97gCllJA9lDW6IzHAHRQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5211 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ajay Singh Sometimes 'wilc_sdio_cmd53' is called with addresses pointing to an object on the stack. Use dynamically allocated memory for cmd53 instead of stack address which is not DMA'able. Fixes: 5625f965d764 ("wilc1000: move wilc driver out of staging") Reported-by: Michael Walle Suggested-by: Michael Walle Signed-off-by: Ajay Singh --- This patch is created based on [1] and changes are done as discussed in the same thread. [1]. https://patchwork.kernel.org/project/linux-wireless/patch/20220728152037.386543-1-michael@walle.cc/ changes since v1: - add 'use_global_buf' variable to know when to use bounce buffer - remove unnecessary goto label - dynamically allocate 'vmm_table' .../net/wireless/microchip/wilc1000/netdev.h | 1 + .../net/wireless/microchip/wilc1000/sdio.c | 35 +++++++++++++++---- .../net/wireless/microchip/wilc1000/wlan.c | 15 ++++++-- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index 43c085c74b7a..bb1a315a7b7e 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -245,6 +245,7 @@ struct wilc { u8 *rx_buffer; u32 rx_buffer_offset; u8 *tx_buffer; + u32 *vmm_table; struct txq_handle txq[NQUEUES]; int txq_entries; diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index 600cc57e9da2..b12f411aec06 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -28,6 +28,7 @@ struct wilc_sdio { u32 block_size; bool isinit; int has_thrpt_enh3; + u8 *cmd53_buf; }; struct sdio_cmd52 { @@ -47,6 +48,7 @@ struct sdio_cmd53 { u32 count: 9; u8 *buffer; u32 block_size; + u8 use_global_buf; }; static const struct wilc_hif_func wilc_hif_sdio; @@ -91,6 +93,8 @@ static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd) { struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev); int size, ret; + struct wilc_sdio *sdio_priv = wilc->bus_data; + u8 *buf = cmd->buffer; sdio_claim_host(func); @@ -101,12 +105,19 @@ static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd) else size = cmd->count; + if (cmd->use_global_buf) + buf = sdio_priv->cmd53_buf; + if (cmd->read_write) { /* write */ - ret = sdio_memcpy_toio(func, cmd->address, - (void *)cmd->buffer, size); + if (cmd->use_global_buf) + memcpy(buf, cmd->buffer, size); + + ret = sdio_memcpy_toio(func, cmd->address, buf, size); } else { /* read */ - ret = sdio_memcpy_fromio(func, (void *)cmd->buffer, - cmd->address, size); + ret = sdio_memcpy_fromio(func, buf, cmd->address, size); + + if (cmd->use_global_buf) + memcpy(cmd->buffer, buf, size); } sdio_release_host(func); @@ -128,6 +139,12 @@ static int wilc_sdio_probe(struct sdio_func *func, if (!sdio_priv) return -ENOMEM; + sdio_priv->cmd53_buf = kzalloc(sizeof(u32), GFP_KERNEL); + if (!sdio_priv->cmd53_buf) { + ret = -ENOMEM; + goto free; + } + ret = wilc_cfg80211_init(&wilc, &func->dev, WILC_HIF_SDIO, &wilc_hif_sdio); if (ret) @@ -161,6 +178,7 @@ static int wilc_sdio_probe(struct sdio_func *func, irq_dispose_mapping(wilc->dev_irq_num); wilc_netdev_cleanup(wilc); free: + kfree(sdio_priv->cmd53_buf); kfree(sdio_priv); return ret; } @@ -172,6 +190,7 @@ static void wilc_sdio_remove(struct sdio_func *func) clk_disable_unprepare(wilc->rtc_clk); wilc_netdev_cleanup(wilc); + kfree(sdio_priv->cmd53_buf); kfree(sdio_priv); } @@ -375,8 +394,9 @@ static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, u32 data) cmd.address = WILC_SDIO_FBR_DATA_REG; cmd.block_mode = 0; cmd.increment = 1; - cmd.count = 4; + cmd.count = sizeof(u32); cmd.buffer = (u8 *)&data; + cmd.use_global_buf = 1; cmd.block_size = sdio_priv->block_size; ret = wilc_sdio_cmd53(wilc, &cmd); if (ret) @@ -414,6 +434,7 @@ static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) nblk = size / block_size; nleft = size % block_size; + cmd.use_global_buf = 0; if (nblk > 0) { cmd.block_mode = 1; cmd.increment = 1; @@ -492,8 +513,9 @@ static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data) cmd.address = WILC_SDIO_FBR_DATA_REG; cmd.block_mode = 0; cmd.increment = 1; - cmd.count = 4; + cmd.count = sizeof(u32); cmd.buffer = (u8 *)data; + cmd.use_global_buf = 1; cmd.block_size = sdio_priv->block_size; ret = wilc_sdio_cmd53(wilc, &cmd); @@ -535,6 +557,7 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) nblk = size / block_size; nleft = size % block_size; + cmd.use_global_buf = 0; if (nblk > 0) { cmd.block_mode = 1; cmd.increment = 1; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 947d9a0a494e..58bbf50081e4 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -714,7 +714,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) int ret = 0; int counter; int timeout; - u32 vmm_table[WILC_VMM_TBL_SIZE]; + u32 *vmm_table = wilc->vmm_table; u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0}; const struct wilc_hif_func *func; int srcu_idx; @@ -1252,6 +1252,8 @@ void wilc_wlan_cleanup(struct net_device *dev) while ((rqe = wilc_wlan_rxq_remove(wilc))) kfree(rqe); + kfree(wilc->vmm_table); + wilc->vmm_table = NULL; kfree(wilc->rx_buffer); wilc->rx_buffer = NULL; kfree(wilc->tx_buffer); @@ -1489,6 +1491,14 @@ int wilc_wlan_init(struct net_device *dev) goto fail; } + if (!wilc->vmm_table) + wilc->vmm_table = kzalloc(WILC_VMM_TBL_SIZE, GFP_KERNEL); + + if (!wilc->vmm_table) { + ret = -ENOBUFS; + goto fail; + } + if (!wilc->tx_buffer) wilc->tx_buffer = kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL); @@ -1513,7 +1523,8 @@ int wilc_wlan_init(struct net_device *dev) return 0; fail: - + kfree(wilc->vmm_table); + wilc->vmm_table = NULL; kfree(wilc->rx_buffer); wilc->rx_buffer = NULL; kfree(wilc->tx_buffer);