Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5627364rwl; Wed, 28 Dec 2022 23:43:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXuos0QGgwwbTlyzUIfxuTGpLjYt9ZsChZ8esytlt6JaCafgJmi+/hwnFdRaEFdk0ANPtUCR X-Received: by 2002:a17:906:30c9:b0:78d:f457:1052 with SMTP id b9-20020a17090630c900b0078df4571052mr23009579ejb.15.1672299793551; Wed, 28 Dec 2022 23:43:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672299793; cv=none; d=google.com; s=arc-20160816; b=jZoZUi9rmM97lPkcyBKW8CqABeU5Pyy/BFn6NxA2/jqNawtq9zgP/mkt18HzVvj0k3 lVOA4lFjibYFzjH+sg3PL5NLgnF2nNkfVO9aZgVXux/7flpKNdght8IlZMnB2vPXmE7H 1QmTV+V4YBoTC6AO70LQt3IZoBHdK0ux2gJl1KrdbgX30rYwEXU+uieM5BQvOuFJIG8D c4cNARlfodJFpNllASaOJkuSBY7eIT3pNUW9/ybNLD6n6bQYUL3N/Wrzzws7N2bRbVAY 1Ttnj7blN1lFcJsGoa8GxPC9s/XhPx8sdvmr9LTzBidNpDUGSNyzxg1BLiDcSwtEyzXy PxtQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=FQszMWeXFPAfmDJi4sx+8Hf/q+9+cLOONIJyAQ7Rc8E=; b=kGA0vxqQLn2UTTlC+kIYF3a4GKUXDxMigHKQg2nLqe08sTeEgE/JdBX1+rZO0Yapgl Xv2k6WCYzlOUEy+KgICs7IriaGpXikRCS3+7QUkFM8edRTcaNZdfDIIGr00Bksbdbv46 I7YxYpkI08GF7n/z4qnxVn9HwaCF6wGcQS+T/FM4vwK/MCRNELAuLULggJfydBQkdiRX G+QR/lUd5sE4PXKmy5u4M79S+TBSHAQf460BOjs6qdHtDefPDKcn7u8T0i3SvS96jyZW vGHy5kNdJw7MXmpL/VQEg2+H3Sggje8whqXXUHMily0EcHHk9uNvFAoSNS7+Bd19uR/Y 5OKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=V2xfjPRu; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho14-20020a1709070e8e00b007c0889e324esi16833360ejc.366.2022.12.28.23.42.52; Wed, 28 Dec 2022 23:43:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=V2xfjPRu; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231280AbiL2HjL (ORCPT + 67 others); Thu, 29 Dec 2022 02:39:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232749AbiL2HjA (ORCPT ); Thu, 29 Dec 2022 02:39:00 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E154BCA0; Wed, 28 Dec 2022 23:38:59 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id d10so11893559pgm.13; Wed, 28 Dec 2022 23:38:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FQszMWeXFPAfmDJi4sx+8Hf/q+9+cLOONIJyAQ7Rc8E=; b=V2xfjPRuzPwskYbvlUUr5aTd84JZ1LVV8WNm9c/hLcgcMTOQqDEmf8KlhkO8wRck8q AwhjEutQlv3Uu+uLoV8+F2CdXQxG1aEqg+4tFI5ne2UxiLYPyrKfZGG5Z0Fejw6sUE/c 1z5m3FS2I7M027yFST77lTeTNNUJe3Eu/Lwly2fDXd9jbZzdr+k11oMRATpYktv22ZlK RUOoDlclkWU+nzDMp1a0cGTBV0krvCVw+oTF7F5E+LGQ5PKbIxA7GqZ5b9l60E4TwNHD 9WDAQxQXQ4vCXENwZ+smJsrRNNjosZCCnaqalIobNRcricZjpcMiFcxNAMwokSJfySjD oKBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FQszMWeXFPAfmDJi4sx+8Hf/q+9+cLOONIJyAQ7Rc8E=; b=EXW/y3gVy4wQYo59zG0V0PWw9RyFWJBwHNaWkZGNNohy+deHYkpdTKUWPw8ecoEQWb XP4osVbdV6J/i5k7gtopbdAKIPHuOcXSWrftMhkHpZQsHA1QEo5aPQkNuZlVZCrxN+r2 Bm/fWNl6LzprRM2LM/LD21qV+lOsj01SiIXbJSix4XMwlwyAhk0CoJ1n7k7+ihALYbdz nu2SQxpqrkog2H3P3vQidB+g7iyb0X2mmwor0NL69B+YTDiG5hh2C/axMiER7gMlY0oM Yfy2MDDVc81UvonJumG2HZEaNGKEz5/p/rtJuSTrkI6lB+n7O3Qs0x2HoSdbycLiajor 7nog== X-Gm-Message-State: AFqh2krpbCUONH+Dp2MweduH+5s1uwlAx62w2zsT6KYjQTXUdOqyJkjM hKpwgYXTVmuGGMh6hvgLuz0= X-Received: by 2002:aa7:8502:0:b0:576:a500:2c7c with SMTP id v2-20020aa78502000000b00576a5002c7cmr45101601pfn.27.1672299538685; Wed, 28 Dec 2022 23:38:58 -0800 (PST) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id y17-20020a626411000000b00575b6d7c458sm11401168pfb.21.2022.12.28.23.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 23:38:58 -0800 (PST) From: Miaoqian Lin To: Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Manikanta Pubbisetty , ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linmq006@gmail.com Subject: [PATCH] wifi: ath11k: Fix memory leak in ath11k_peer_rx_frag_setup Date: Thu, 29 Dec 2022 11:38:48 +0400 Message-Id: <20221229073849.1388315-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org crypto_alloc_shash() allocates resources, which should be released by crypto_free_shash(). When ath11k_peer_find() fails, there has memory leak. Move crypto_alloc_shash() after ath11k_peer_find() to fix this. Fixes: 243874c64c81 ("ath11k: handle RX fragments") Signed-off-by: Miaoqian Lin --- drivers/net/wireless/ath/ath11k/dp_rx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index c5a4c34d7749..1297caa2b09a 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -3116,10 +3116,6 @@ int ath11k_peer_rx_frag_setup(struct ath11k *ar, const u8 *peer_mac, int vdev_id struct dp_rx_tid *rx_tid; int i; - tfm = crypto_alloc_shash("michael_mic", 0, 0); - if (IS_ERR(tfm)) - return PTR_ERR(tfm); - spin_lock_bh(&ab->base_lock); peer = ath11k_peer_find(ab, vdev_id, peer_mac); @@ -3129,6 +3125,10 @@ int ath11k_peer_rx_frag_setup(struct ath11k *ar, const u8 *peer_mac, int vdev_id return -ENOENT; } + tfm = crypto_alloc_shash("michael_mic", 0, 0); + if (IS_ERR(tfm)) + return PTR_ERR(tfm); + for (i = 0; i <= IEEE80211_NUM_TIDS; i++) { rx_tid = &peer->rx_tid[i]; rx_tid->ab = ab; -- 2.25.1