From patchwork Thu Dec 29 07:38:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 37318 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2280327wrt; Wed, 28 Dec 2022 23:44:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXvf+mDybK4u0OGhSMreCHs33lJbP33ZaviYdMxPNCF1f/kV8rzHuGgiBu5unxefnKraXTIn X-Received: by 2002:a17:907:8b12:b0:78d:f457:1062 with SMTP id sz18-20020a1709078b1200b0078df4571062mr23862557ejc.31.1672299896242; Wed, 28 Dec 2022 23:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672299896; cv=none; d=google.com; s=arc-20160816; b=YegkTcVuNo34mOI51n+8BD/q5Z6n3Douw3W/tHpffBD8zIi5i1Ckax+OmGJfefcJzD jZpZjc6iY4SDhYSUD6J3LbGaaedxeSbvjXEu7NB8l2Vwq1qq099OU1sy2lwKrTCHyIS1 GYq7WuufmiKvS/TPn9zjhsyD2eFl+9VQn+NMJ1KSxXOjCUvW1dNs8NhMpHOcr4hKMwhp YiFK6o3sjH3luxZLWlQtG26Y3WnO1YJLkaHnCkPCk6RcEf0SqXzk0nPgPxEwGSIQX63e XqGz+Autgrr5LXVe5/wQa434s+XuYschD7T426SdXhlQpaiGKnHAQwKXiKqkEF8s4Qvy obaw== 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=AU8l8Lp6WEfrq1tbOK5G6rasiksIaj7rmYOCINNZs+BKdMrTBiBAAJzQ7BMPOjz0BT q/FWNdyVQ4xMtS68XZ90G+Gw2tMZcOjJ0sLXJ7fkgbAtBHguZRhm5HGUNY98q5VwCRxc N8L0pf07zKYyk3rUQgjP/Ojoke+zyh830vb2IXdvq1r3GysTElmuLBl9Yl5sIG4D4dny wELN1TNHCONiqyXDQiM2ohwyfEb3ZHuU/rEgA4kEoFWrZ+2I088XozOzRtCGYLi7nyT8 JzNiOG32arr16x666wqxsK+iJaXAfBfj8HlLcaRNYGikXRZ4wpud/ttngX+bOL7CRcIy xgSg== 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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn20-20020a17090794d400b007baa6e22759si15148194ejc.226.2022.12.28.23.44.32; Wed, 28 Dec 2022 23:44:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S231203AbiL2HjO (ORCPT + 99 others); Thu, 29 Dec 2022 02:39:14 -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 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753533536053362581?= X-GMAIL-MSGID: =?utf-8?q?1753533536053362581?= 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;