From patchwork Thu May 20 09:21:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 443163 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp2110768jac; Thu, 20 May 2021 02:25:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzczcMItlTRZLt6d9AcOtAZby/dSxJOlxU9OexFYhsEYNqm7Mep20P74uSfn86ql62dXFHY X-Received: by 2002:a5e:a619:: with SMTP id q25mr4106941ioi.95.1621502759789; Thu, 20 May 2021 02:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621502759; cv=none; d=google.com; s=arc-20160816; b=Y2QfW6cEmMh/yFOdkxgxfUeq1H/2MDN8CycveRHNU4WFsYAfxZwF9sSRv/FhK8osqh 9if/xVd8n1clUqKdA7Ho103WKMk3Yck0YYrsw5x166HxL7E9Y+yGf0d1T98GKEJ87awv 0gLzk0Rpp4pWMLfxRxgyVbsP9Jj1LaAeA1r5KJ848MNTBIfuqD6F/k35eFVf67dV8FGB /UTeWXwf2/YiDeFlJsmTpyahI7TngoaeHXdubftp/dE/g1PfVMk/yXYTgUymuRExafQl BtCKQneXfIFlXSwwSb1ynb3WCwLb0BpwBm4tPgL2BN89koX6XQ10SamF2KIogk6ysxeh SmDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eLQnqGghoixxW8GMXB0Wl25dLLhGrMLIJ1k0c4a9x+Y=; b=kI6AxxPEDdTNynHpbPmpTzU8cvXs6IKuH2bgj45W/CLhmtx/GJ1swyB7PG3IGaNhTJ 7kITBPSxGSPjw1ehqgTjMWMJTGkNU6Um9OMaFNWR4q/FuzvLybE1lvEW+x6x+gLiVA/S P5qH3WoLhhVLnKKaWtP3lDPzFib/Z/OPWUYf/58zloBGS9GqkDCxaFjgbdzhr0Aix4Zu of7Rmr8eC1Qy2IfgWln2gg4g7pT8ffAZh9cHhYYQQmK1a4pJvwfLi+d7Xq7qFdprs76m 6+AI0RSxjFNWQF/QIUbWZqgYAXEovV2hFl7rOZr4BCb/4P1d2tcdbAbX0ZQ/crFUlwrI GBZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vnm4wFBI; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si2133137iot.35.2021.05.20.02.25.59; Thu, 20 May 2021 02:25:59 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vnm4wFBI; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231479AbhETJ1O (ORCPT + 12 others); Thu, 20 May 2021 05:27:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:53360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231712AbhETJ0q (ORCPT ); Thu, 20 May 2021 05:26:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 077776124C; Thu, 20 May 2021 09:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621502724; bh=t4l8X66dHNKfmW/w/iiMeOjsLdJtpusMCN7H9nWc6YE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vnm4wFBId/KvQ8uGAsaaE1hdNbw3H6iMb0Dt2gKdNd4tNyuhYJbZQcfJw0SJW/xil tbgh1FHoBkuswXK4L4s6bxwDpptlQ6CkglOauddkDqDlld+p+a1b6uTRfLHaS58QLL f1JtltWxJHHJbATIOhdeljY1549BvsFxA83x5gYM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Kalle Valo Subject: [PATCH 5.12 03/45] airo: work around stack usage warning Date: Thu, 20 May 2021 11:21:51 +0200 Message-Id: <20210520092053.630691529@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092053.516042993@linuxfoundation.org> References: <20210520092053.516042993@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann commit 7909a590eba6d021f104958857cbc4f0089daceb upstream. gcc-11 with KASAN on 32-bit arm produces a warning about a function that needs a lot of stack space: drivers/net/wireless/cisco/airo.c: In function 'setup_card.constprop': drivers/net/wireless/cisco/airo.c:3960:1: error: the frame size of 1512 bytes is larger than 1400 bytes [-Werror=frame-larger-than=] Most of this is from a single large structure that could be dynamically allocated or moved into the per-device structure. However, as the callers all seem to have a fairly well bounded call chain, the easiest change is to pull out the part of the function that needs the large variables into a separate function and mark that as noinline_for_stack. This does not reduce the total stack usage, but it gets rid of the warning and requires minimal changes otherwise. Signed-off-by: Arnd Bergmann Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20210323131634.2669455-1-arnd@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/cisco/airo.c | 117 +++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 52 deletions(-) --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -3817,6 +3817,68 @@ static inline void set_auth_type(struct local->last_auth = auth_type; } +static int noinline_for_stack airo_readconfig(struct airo_info *ai, u8 *mac, int lock) +{ + int i, status; + /* large variables, so don't inline this function, + * maybe change to kmalloc + */ + tdsRssiRid rssi_rid; + CapabilityRid cap_rid; + + kfree(ai->SSID); + ai->SSID = NULL; + // general configuration (read/modify/write) + status = readConfigRid(ai, lock); + if (status != SUCCESS) return ERROR; + + status = readCapabilityRid(ai, &cap_rid, lock); + if (status != SUCCESS) return ERROR; + + status = PC4500_readrid(ai, RID_RSSI, &rssi_rid, sizeof(rssi_rid), lock); + if (status == SUCCESS) { + if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL) + memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */ + } + else { + kfree(ai->rssi); + ai->rssi = NULL; + if (cap_rid.softCap & cpu_to_le16(8)) + ai->config.rmode |= RXMODE_NORMALIZED_RSSI; + else + airo_print_warn(ai->dev->name, "unknown received signal " + "level scale"); + } + ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS; + set_auth_type(ai, AUTH_OPEN); + ai->config.modulation = MOD_CCK; + + if (le16_to_cpu(cap_rid.len) >= sizeof(cap_rid) && + (cap_rid.extSoftCap & cpu_to_le16(1)) && + micsetup(ai) == SUCCESS) { + ai->config.opmode |= MODE_MIC; + set_bit(FLAG_MIC_CAPABLE, &ai->flags); + } + + /* Save off the MAC */ + for (i = 0; i < ETH_ALEN; i++) { + mac[i] = ai->config.macAddr[i]; + } + + /* Check to see if there are any insmod configured + rates to add */ + if (rates[0]) { + memset(ai->config.rates, 0, sizeof(ai->config.rates)); + for (i = 0; i < 8 && rates[i]; i++) { + ai->config.rates[i] = rates[i]; + } + } + set_bit (FLAG_COMMIT, &ai->flags); + + return SUCCESS; +} + + static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) { Cmd cmd; @@ -3863,58 +3925,9 @@ static u16 setup_card(struct airo_info * if (lock) up(&ai->sem); if (ai->config.len == 0) { - int i; - tdsRssiRid rssi_rid; - CapabilityRid cap_rid; - - kfree(ai->SSID); - ai->SSID = NULL; - // general configuration (read/modify/write) - status = readConfigRid(ai, lock); - if (status != SUCCESS) return ERROR; - - status = readCapabilityRid(ai, &cap_rid, lock); - if (status != SUCCESS) return ERROR; - - status = PC4500_readrid(ai, RID_RSSI,&rssi_rid, sizeof(rssi_rid), lock); - if (status == SUCCESS) { - if (ai->rssi || (ai->rssi = kmalloc(512, GFP_KERNEL)) != NULL) - memcpy(ai->rssi, (u8*)&rssi_rid + 2, 512); /* Skip RID length member */ - } - else { - kfree(ai->rssi); - ai->rssi = NULL; - if (cap_rid.softCap & cpu_to_le16(8)) - ai->config.rmode |= RXMODE_NORMALIZED_RSSI; - else - airo_print_warn(ai->dev->name, "unknown received signal " - "level scale"); - } - ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS; - set_auth_type(ai, AUTH_OPEN); - ai->config.modulation = MOD_CCK; - - if (le16_to_cpu(cap_rid.len) >= sizeof(cap_rid) && - (cap_rid.extSoftCap & cpu_to_le16(1)) && - micsetup(ai) == SUCCESS) { - ai->config.opmode |= MODE_MIC; - set_bit(FLAG_MIC_CAPABLE, &ai->flags); - } - - /* Save off the MAC */ - for (i = 0; i < ETH_ALEN; i++) { - mac[i] = ai->config.macAddr[i]; - } - - /* Check to see if there are any insmod configured - rates to add */ - if (rates[0]) { - memset(ai->config.rates, 0, sizeof(ai->config.rates)); - for (i = 0; i < 8 && rates[i]; i++) { - ai->config.rates[i] = rates[i]; - } - } - set_bit (FLAG_COMMIT, &ai->flags); + status = airo_readconfig(ai, mac, lock); + if (status != SUCCESS) + return ERROR; } /* Setup the SSIDs if present */