From patchwork Sat Jun 5 17:33:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 454696 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1421568jae; Sat, 5 Jun 2021 10:32:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8Z5gKa/WR9QuASGUAFfJfO2kCDVXmJYJb39Licpmqc/XNYp2yzOENlCb3S5ANAfQdyFZh X-Received: by 2002:a50:ed82:: with SMTP id h2mr11556543edr.140.1622914332283; Sat, 05 Jun 2021 10:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622914332; cv=none; d=google.com; s=arc-20160816; b=tGyFfnNPzyR7mbH5icA0ljgqRU+kF6kkqB/lRe/orHHO71PZmkAl56hNZGYkvaM4Y3 Jx4oJasYtAfvnRe7WbbU0sZqJFTk+MS4e+Fhlj6BOz+m1WtoBxitXsr9u85VEwMWJWAy F1kNTGwyZM9kKPHrLaAK3gm2AQU1LU5qHBKzR6Q9Es7ZuTGat3jKIiNabPOf88f2FH9s ECiirqzKK+erdBMsCiDUmd6oh/av8lkgyseZYYG//7nopCPV35Tl2vyFPpAmTw+xwzMU CpRmZZ9SMKVFdgnu9T8yAR9iY/H80NDt6wpWI90Dhh6XUjHqolXSWWyBU4EBg7n+stfK jsxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature; bh=yIHJ5MnUhX3KKx/2SAWVZTEFhIewkacwxZb3t8C3RZQ=; b=aMmCdDJlXpr711Zbnw6tb1wZF+VfaOdQGopt0TYUXG1m22WHIW7+dthls2AbghTlCw 82uEggBilePxr3ZCNtAJsApEpSRlIZVRi7SvrJkDv2SnyvvfO0gNfYxe9jLz0V8Hv/4z SEpXZUlsvsVFNUkNwJkQjxpSawCIe8vObEsWQAqrMD013Nn2F1JhNbTH1BsyIVUEa3cV J915m1buPuny5p0VsOlcQ3FIfsqMP/Ew7SzWQJTZGChR3OWGHSNjWOde2EhRTiVPVsqI Ey6ihJ4zcTiU6Lqmp5CYklJYvDIfOGxeUFcRfX5wgCiv1UPiqs7CgqnI/gtJjwz954yd 1OaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=ireygWee; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="Qw/VHqv4"; spf=pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id w12si7568783edv.297.2021.06.05.10.32.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Jun 2021 10:32:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=ireygWee; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="Qw/VHqv4"; spf=pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=yIHJ5MnUhX3KKx/2SAWVZTEFhIewkacwxZb3t8C3RZQ=; b=ireygWeeAhzHop mktA+IMEgBU9ILvbrDn4Qkfthcl6xF2jddxuJWlvjNvcM06zN7PO80HRrcNzZ7lrz4QmZthvlwLC5 Mj4h6jiuNveW5rzYhP0qi1ZDLdOeCA0fEMcb4DWpaKmx6bc+QKT9d7y44qPhDbR8QY9fntCI84ko1 Ou1OH0LKTxemroqIF81UfLnAIJsGXyEkHPPRY+8pb78ASp6Gg8t/a4paix6YHNGlH7DkLtJMGX48M Vno6FEkgCJosuqDnyfZkY9bu6Z+KRN+fo1eYgID23NBh35BUDr8gYe0ydrlDlLRhxqN/cZoDgeypP zB2Tycih4+h+/GC0VzxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpa9X-00GrrL-2D; Sat, 05 Jun 2021 17:32:07 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpa9U-00Grr0-KF for wcn36xx@lists.infradead.org; Sat, 05 Jun 2021 17:32:05 +0000 Received: by mail-wr1-x431.google.com with SMTP id e11so2293635wrg.3 for ; Sat, 05 Jun 2021 10:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=F2I4qe28xHz443ZJOjbjuXHYaoVOQnlSqV81AqbJSsI=; b=Qw/VHqv44F9j/5r+l25fyyrsi6AJJzJijYwgne/GrKJVMSJK8LvPFAp4TAd+CpNHOC AsudxG1rNS3oDtZVYzx76zlHUBI4XNKFjlSN4oyazSUayEiBkfZpZ0KumlOaKZWzxd9l iSnOQhN6IVeZNtjVVMpSY9zGA6AlYMGvGzZeXZnn8yc6THIWepndLneWxEEWj0VciAEl Ej1HCkewGBbS7NfWso/dd8G5fZmEOZ6pOL2ciyZwXmeCAcVvr/8tSinAtv1IQ6xXVcAs Fbn2N5Xi9lHXcbIIw1rD6ytOUcYpNTVrNalIEvBZ03D6wOQoKQXqKnqHiwloEoxYyP7D 8lBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=F2I4qe28xHz443ZJOjbjuXHYaoVOQnlSqV81AqbJSsI=; b=Id/icSmN8kTQcou2qeFQ7UUoUvPyvEukIxHMLPIzNSCKyiiI8ITiqWXZP94liYx4Od OYCMeaYa8/OIR7a1GB3tBWd8emciS91lBBrjRxVv6VxNi7M9pDms+uEqDbSkgynow2dF r768er5TU67oT5+nkjS+LQlt3BXB+8VSVK2aBLklMvxJh4b5SCAg58VL78aiKh/siivA RtTS4ImxN+qxz7AoOqlafmui0ygyGNfyjKV0Xr5DuavGihSQ4CuktWq9wLs4z3/1fSmH xl1OnIAkC8HPjZGuLP6TMiPfHLck1afG/YRFtEc+E+WH1RNI4SF7XzY/LlzoWR4k6PaJ G61A== X-Gm-Message-State: AOAM53371VdYTUtPu6yWaZkizKWKCJOqJ1Ay+JdnpFHZKxbdbSggwoab wzp/TaH+vqLR+EY4KIiHWfUxGg== X-Received: by 2002:a5d:618f:: with SMTP id j15mr4208786wru.348.1622914322924; Sat, 05 Jun 2021 10:32:02 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id g186sm2520660wme.6.2021.06.05.10.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Jun 2021 10:32:02 -0700 (PDT) From: Bryan O'Donoghue To: kvalo@codeaurora.org, wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org Cc: bryan.odonoghue@linaro.org, shawn.guo@linaro.org, benl@squareup.com, loic.poulain@linaro.org, bjorn.andersson@linaro.org Subject: [PATCH] wcn36xx: Move hal_buf allocation to devm_kmalloc in probe Date: Sat, 5 Jun 2021 18:33:47 +0100 Message-Id: <20210605173347.2266003-1-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210605_103204_719578_C2650DC8 X-CRM114-Status: GOOD ( 12.04 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Right now wcn->hal_buf is allocated in wcn36xx_start(). This is a problem since we should have setup all of the buffers we required by the time ieee80211_register_hw() is called. struct ieee80211_ops callbacks may run prior to mac_start() and therefore wcn->hal_buf must be initialized. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:431 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: wcn36xx@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "wcn36xx" Errors-To: wcn36xx-bounces+patch=linaro.org@lists.infradead.org Right now wcn->hal_buf is allocated in wcn36xx_start(). This is a problem since we should have setup all of the buffers we required by the time ieee80211_register_hw() is called. struct ieee80211_ops callbacks may run prior to mac_start() and therefore wcn->hal_buf must be initialized. This is easily remediated by moving the allocation to probe() taking the opportunity to tidy up freeing memory by using devm_kmalloc(). Fixes: 8e84c2582169 ('wcn36xx: mac80211 driver for Qualcomm WCN3660/WCN3680 hardware') Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/main.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) -- 2.30.1 _______________________________________________ wcn36xx mailing list wcn36xx@lists.infradead.org http://lists.infradead.org/mailman/listinfo/wcn36xx Reviewed-by: Bjorn Andersson diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index 84e117e0546c..2ccf7a8924a0 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -296,23 +296,16 @@ static int wcn36xx_start(struct ieee80211_hw *hw) goto out_free_dxe_pool; } - wcn->hal_buf = kmalloc(WCN36XX_HAL_BUF_SIZE, GFP_KERNEL); - if (!wcn->hal_buf) { - wcn36xx_err("Failed to allocate smd buf\n"); - ret = -ENOMEM; - goto out_free_dxe_ctl; - } - ret = wcn36xx_smd_load_nv(wcn); if (ret) { wcn36xx_err("Failed to push NV to chip\n"); - goto out_free_smd_buf; + goto out_free_dxe_ctl; } ret = wcn36xx_smd_start(wcn); if (ret) { wcn36xx_err("Failed to start chip\n"); - goto out_free_smd_buf; + goto out_free_dxe_ctl; } if (!wcn36xx_is_fw_version(wcn, 1, 2, 2, 24)) { @@ -339,8 +332,6 @@ static int wcn36xx_start(struct ieee80211_hw *hw) out_smd_stop: wcn36xx_smd_stop(wcn); -out_free_smd_buf: - kfree(wcn->hal_buf); out_free_dxe_ctl: wcn36xx_dxe_free_ctl_blks(wcn); out_free_dxe_pool: @@ -375,8 +366,6 @@ static void wcn36xx_stop(struct ieee80211_hw *hw) wcn36xx_dxe_free_mem_pools(wcn); wcn36xx_dxe_free_ctl_blks(wcn); - - kfree(wcn->hal_buf); } static void wcn36xx_change_ps(struct wcn36xx *wcn, bool enable) @@ -1499,6 +1488,12 @@ static int wcn36xx_probe(struct platform_device *pdev) mutex_init(&wcn->hal_mutex); mutex_init(&wcn->scan_lock); + wcn->hal_buf = devm_kmalloc(wcn->dev, WCN36XX_HAL_BUF_SIZE, GFP_KERNEL); + if (!wcn->hal_buf) { + ret = -ENOMEM; + goto out_wq; + } + ret = dma_set_mask_and_coherent(wcn->dev, DMA_BIT_MASK(32)); if (ret < 0) { wcn36xx_err("failed to set DMA mask: %d\n", ret);