From patchwork Thu Nov 7 13:33:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 842676 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 510CF2114 for ; Thu, 7 Nov 2024 13:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986424; cv=none; b=chCd8uf4oRYQxwsCZ+7cRrhzWIRrC9iTFxt0FPM2vTjkql5oN8W8D4HiWsGlFhKmyfhmruZCn56UtaPcD3MVh5yKJ+KEZirgEJ55BvfXSpvDz7D1gZwrkp9eb/K+pOhejnNXuBAOw6E7WJOiC/R9tkPO8nPn18UgcSmi3c7oA7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986424; c=relaxed/simple; bh=qmyB7RvdNqhL2/+qnrBNdaUlxHQQWE3vlW1VezqLvis=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f0gCY5p3PVmEjDIQqOh6SXglj4+EIONK3nbB7omBjsDhw/3Ys4KhBQJaFTTdQf462UXNrxWkoAXQIuh1ZVgPtLEElIOoCKqOL32t540oFa3RhxJxmihzUiWbOQsq1qWIa99QWq8Ghd8a15e7eMLaQU59AG04Wc7fhrCISWt9ERw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=J102/wJs; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="J102/wJs" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LYDXE076F/eAzArSQ+e5oOtPnWZO9qzk5KrLH/ONKm8=; b=J102/wJsHWOKpgqUSN+3lX3Pt/ p6bh77QkutAXPs4z/AGnDrNTYv0AABzNNHA+exVtY7D0P6+QmS7loOWH4AQGXPaD4Frk/zlKoU0u4 SbOYyuU490Jn6wmuKWcZpcfSnOZv4CNrhSexVFHoVy79MTJwlsrLU7rnMCAHbE98yKs0fUW9+iw+q eXYVXjJmIsybSpgaaLlrYW6hL8WOSFKSZxArN2Fc7ZphwPY4l2hYGQbuCAwnPd529cJqv86fPnyiG uW1PBRuioF3soSWF4GeyOkyrb43W/j+q5a6V3Z1u4MEuPNgvgg/ETKeYFHZOHcOBDyzSgd+4FvK/J fARSBk+Q==; Received: from 179-125-64-253-dinamico.pombonet.net.br ([179.125.64.253] helo=quatroqueijos.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t92dm-003Zsz-F8; Thu, 07 Nov 2024 14:33:39 +0100 From: Thadeu Lima de Souza Cascardo To: linux-wireless@vger.kernel.org Cc: Ping-Ke Shih , Kalle Valo , kernel-dev@igalia.com, Thadeu Lima de Souza Cascardo Subject: [PATCH net 1/5] wifi: rtlwifi: do not complete firmware loading needlessly Date: Thu, 7 Nov 2024 10:33:18 -0300 Message-Id: <20241107133322.855112-2-cascardo@igalia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107133322.855112-1-cascardo@igalia.com> References: <20241107133322.855112-1-cascardo@igalia.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The only code waiting for completion is driver removal, which will not be called when probe returns a failure. So this completion is unnecessary. Fixes: b0302aba812b ("rtlwifi: Convert to asynchronous firmware load") Signed-off-by: Thadeu Lima de Souza Cascardo --- drivers/net/wireless/realtek/rtlwifi/pci.c | 1 - drivers/net/wireless/realtek/rtlwifi/usb.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c index 11709b6c83f1..40fc3c297a8a 100644 --- a/drivers/net/wireless/realtek/rtlwifi/pci.c +++ b/drivers/net/wireless/realtek/rtlwifi/pci.c @@ -2266,7 +2266,6 @@ int rtl_pci_probe(struct pci_dev *pdev, pci_iounmap(pdev, (void __iomem *)rtlpriv->io.pci_mem_start); pci_release_regions(pdev); - complete(&rtlpriv->firmware_loading_complete); fail1: if (hw) diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c index d37a017b2b81..c3aa0cd9ff21 100644 --- a/drivers/net/wireless/realtek/rtlwifi/usb.c +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c @@ -1040,7 +1040,6 @@ int rtl_usb_probe(struct usb_interface *intf, error_out2: _rtl_usb_io_handler_release(hw); usb_put_dev(udev); - complete(&rtlpriv->firmware_loading_complete); kfree(rtlpriv->usb_data); ieee80211_free_hw(hw); return -ENODEV; From patchwork Thu Nov 7 13:33:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 841699 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7D6720FAA2 for ; Thu, 7 Nov 2024 13:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986426; cv=none; b=ssFvtYWr8WXAhSgMIaOGdor/zpk8Wunpkww3mqzXMAK5MvqxbUjwvg2BCwltxnrtoYzGNPHX3ZYCMmMXWOPK8cmGCGnkzNCtOKYl+etxzXtwnd1V22YmkmH3S8NHLnagQbP2HFy5ZfLZ9TeQ7bP4+90Pn+wpxlRPbx6PoZPxvKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986426; c=relaxed/simple; bh=Mujlp8F4WdBBBXP9ogkzZnJvEwIE283S23NcqLfmEs8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=u5BeS4jDUVb5Hi+Q7szH1Y2M3pkAC1FwUqAASH+NKJhLaYsJILNy81Yj7jhMnTyTgsiCDsIOD2SH10Mwa/iIOdP3Qa/yWY9e650yrTFzPr0kenaUv+Z1lwMu3NHBarPDwpyHFDq59KSk5h4gKH2qKTJTp5nkaqN3SMiHh3JKkFQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=of86pK5J; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="of86pK5J" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WW/Cyrl5gTAPbK9GlkFqWkrgh4JE370WcQepVQicaKY=; b=of86pK5JETZzAMZRZbL0yHxsMA UQkUYc32fiFy18udPJTCRg0Gx6oxDPCiO3EmcAf4mHM8XRPpyqgFFlVJlLPpQSHtL2nQEnDOtdqZQ WoTqNHxfXTKm3v+bg8cEhxr9A4opJFYP/aCRkg/JTaN0KeauDspk1lyBRhAO8kMghuQxfB6Txnaxv 6v2M0fFYQTToKpNJzPUUKmxxGPfY3on1Fm9xTKUNZkh9Hs6fSsllQC0OLrqiMOwLzHN0Dlp0J4zlG MW4xGcBOfKp5n0QdxtAXa61ZUm+Phg3mULNrnXijtiV59G/XEq9fvkBos+iZd5G/L10A34nCcUYWm KcU4B3rg==; Received: from 179-125-64-253-dinamico.pombonet.net.br ([179.125.64.253] helo=quatroqueijos.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t92dq-003Zsz-9M; Thu, 07 Nov 2024 14:33:42 +0100 From: Thadeu Lima de Souza Cascardo To: linux-wireless@vger.kernel.org Cc: Ping-Ke Shih , Kalle Valo , kernel-dev@igalia.com, Thadeu Lima de Souza Cascardo Subject: [PATCH net 2/5] wifi: rtlwifi: rtl8192se: rise completion of firmware loading as last step Date: Thu, 7 Nov 2024 10:33:19 -0300 Message-Id: <20241107133322.855112-3-cascardo@igalia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107133322.855112-1-cascardo@igalia.com> References: <20241107133322.855112-1-cascardo@igalia.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Just like in commit 4dfde294b979 ("rtlwifi: rise completion at the last step of firmware callback"), only signal completion once the function is finished. Otherwise, the module removal waiting for the completion could free the memory that the callback will still use before returning. Fixes: b0302aba812b ("rtlwifi: Convert to asynchronous firmware load") Signed-off-by: Thadeu Lima de Souza Cascardo Acked-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c index bbf8ff63dced..e63c67b1861b 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c @@ -64,22 +64,23 @@ static void rtl92se_fw_cb(const struct firmware *firmware, void *context) rtl_dbg(rtlpriv, COMP_ERR, DBG_LOUD, "Firmware callback routine entered!\n"); - complete(&rtlpriv->firmware_loading_complete); if (!firmware) { pr_err("Firmware %s not available\n", fw_name); rtlpriv->max_fw_size = 0; - return; + goto exit; } if (firmware->size > rtlpriv->max_fw_size) { pr_err("Firmware is too big!\n"); rtlpriv->max_fw_size = 0; release_firmware(firmware); - return; + goto exit; } pfirmware = (struct rt_firmware *)rtlpriv->rtlhal.pfirmware; memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size); pfirmware->sz_fw_tmpbufferlen = firmware->size; release_firmware(firmware); +exit: + complete(&rtlpriv->firmware_loading_complete); } static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) From patchwork Thu Nov 7 13:33:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 842675 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22E072101BF for ; Thu, 7 Nov 2024 13:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986429; cv=none; b=EA+sLZ1kG5p+iJi2J9S0E6AS3kRnlv4H3UNGd/IYvJAbVGlfBeETBncOV9qWciLRhIjGD/ZmKJsP0TLvDyoHFpMeGQRVt0ne0GO40e3MYlvHzTNRh3EW+5+BTWQ1LdkE1gmBKMGHDvyOJUuDgj2IR3hO+001p0HQClDuzyHm2Ts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986429; c=relaxed/simple; bh=bzAU50gtgYaeYf5HMsuxid0+7GYR7kmuUtzYsGfLrBQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rrpw+PBckFt6O4xB8WzjS67c1Jwq70OtJ2ZHmI7Ezk1vWAlQ0fpDTM6Vg8GCWH2puS3QqjwuALDfg1Yo+ekH21ZsoKG9EQhXNEDVKwiNLXKUeOnlbfNd+XgcosYJiCp7NBqMU82w2RnxxqFY7N+nMPGYOdrtWQ03zbo+sN0HKJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=S/Ci8Dax; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="S/Ci8Dax" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=nKAkaAVraMrH3KpRPmD+jKtH0uUtbhfUjK9MHwH4FyU=; b=S/Ci8DaxO2o35lmIiC6Kg4jKnG IEz7hkoFBb1veYwv2zrVmTezIYhnCz4GQIaDp7Yk+nJUck4kfHhxXXJu6Lw33z21Q7bwk1XqQ4vDM PWZpLqCLj9pGDCjxTJvSeR29R9QGDUR4uIcZF9mGtOeo25VmY3KgHeoSVk9OELqXWYIMPsTdJyUIR fja5lT4rNlUxS13zqhvx+vy/CSsOGJKpY7W9EPiFhyRpiom1e74PhkaJyCm2n7RF1R3uju8JqaedR d6liM1M7OZUiFnatLp57Ki6C8m6C7xOd+Ag3sDfysknwPMmObE/9pjXWTYqD2Nq8I9AYUB4jnVgHj giL0Mdqg==; Received: from 179-125-64-253-dinamico.pombonet.net.br ([179.125.64.253] helo=quatroqueijos.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t92dt-003Zsz-HL; Thu, 07 Nov 2024 14:33:46 +0100 From: Thadeu Lima de Souza Cascardo To: linux-wireless@vger.kernel.org Cc: Ping-Ke Shih , Kalle Valo , kernel-dev@igalia.com, Thadeu Lima de Souza Cascardo Subject: [PATCH net 3/5] wifi: rtlwifi: wait for firmware loading before releasing memory Date: Thu, 7 Nov 2024 10:33:20 -0300 Message-Id: <20241107133322.855112-4-cascardo@igalia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107133322.855112-1-cascardo@igalia.com> References: <20241107133322.855112-1-cascardo@igalia.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 At probe error path, the firmware loading work may have already been queued. In such a case, it will try to access memory allocated by the probe function, which is about to be released. In such paths, wait for the firmware worker to finish before releasing memory. Fixes: a7f7c15e945a ("rtlwifi: rtl8192cu: Free ieee80211_hw if probing fails") Signed-off-by: Thadeu Lima de Souza Cascardo --- drivers/net/wireless/realtek/rtlwifi/usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c index c3aa0cd9ff21..c27b116ccdff 100644 --- a/drivers/net/wireless/realtek/rtlwifi/usb.c +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c @@ -1028,13 +1028,15 @@ int rtl_usb_probe(struct usb_interface *intf, err = ieee80211_register_hw(hw); if (err) { pr_err("Can't register mac80211 hw.\n"); - goto error_out; + goto error_init_vars; } rtlpriv->mac80211.mac80211_registered = 1; set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status); return 0; +error_init_vars: + wait_for_completion(&rtlpriv->firmware_loading_complete); error_out: rtl_deinit_core(hw); error_out2: From patchwork Thu Nov 7 13:33:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 841698 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4342B212183 for ; Thu, 7 Nov 2024 13:33:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986432; cv=none; b=J/oyJHBw9w6TO4EyO61R3PaI2NQSZ0hVBIfZFg9sBqqlyX8nLLmE61pbHWxyevpBMeAiue1CHVD+Apywfc97FHQePgUiYa3qe6SNHWKqd5nYAVBNJMomCZB/pUi1R1TrKXt9HBDGn78pYB75n4k/K0b7jKek+1bqFoMe8Sh57jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986432; c=relaxed/simple; bh=DHFZyEm/apIJ/dTvbijqwmQUA2e7pWObYwPzrk3pPXo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=imyYXuc4PMepNW5fIRTnhYgKsyN+v559B8w/YT8P/2SsS20GwmzdYKyICREhMn9eAp+Xkgaj13cB1/dLgqqtLpAm6nOAbS6TqDroCtTyJSNgE5hOfo2gD/IwIEmGNE3KkcpdlBa3TaWwBhgSZlSci0ysJqoZAc5whRuzu8Hvz40= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=FvHK6Rg+; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="FvHK6Rg+" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DNfyb8bUHFkUSScg467npum/PYZA6co9bIdPu4qi2Xo=; b=FvHK6Rg+mwBCESdI94GEaLeXhJ YmVE6Y21Sxr+CIiKMjUA25wQqbbE7urTUTW1JECUHHdKpsjLxZL72IE6OHyOMogErH45Gw4MJY2qf WQR3/6g+Q3DyWDHWxwWEHBVp/DVp5C1bEQa30dZCgW9JYmFJhyzZekzz8C7Np0PKtEiVoJnSo+r2w OUEnQCg452QgzeqQzzmGKM1d1gsAFVHdILS4g7+iWgUfTxcVTZDDUytS0bLMA6MbGx05qFwRticMx pVCeqTtgS8MMBlV2Af9X/ZR+02CN4Pis7+nffUErMt1tnw1kGWL62pbYu3mKyoK6xBwiaAXd5FAST gnOxdq0g==; Received: from 179-125-64-253-dinamico.pombonet.net.br ([179.125.64.253] helo=quatroqueijos.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t92dw-003Zsz-Mr; Thu, 07 Nov 2024 14:33:49 +0100 From: Thadeu Lima de Souza Cascardo To: linux-wireless@vger.kernel.org Cc: Ping-Ke Shih , Kalle Valo , kernel-dev@igalia.com, Thadeu Lima de Souza Cascardo Subject: [PATCH net 4/5] wifi: rtlwifi: fix init_sw_vars leak when probe fails Date: Thu, 7 Nov 2024 10:33:21 -0300 Message-Id: <20241107133322.855112-5-cascardo@igalia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107133322.855112-1-cascardo@igalia.com> References: <20241107133322.855112-1-cascardo@igalia.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If ieee80211_register_hw fails, the memory allocated for the firmware will not be released. Call deinit_sw_vars as the function that undoes the allocationes done by init_sw_vars. Fixes: cefe3dfdb9f5 ("rtl8192cu: Call ieee80211_register_hw from rtl_usb_probe") Signed-off-by: Thadeu Lima de Souza Cascardo --- drivers/net/wireless/realtek/rtlwifi/usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c index c27b116ccdff..8ec687fab572 100644 --- a/drivers/net/wireless/realtek/rtlwifi/usb.c +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c @@ -1037,6 +1037,7 @@ int rtl_usb_probe(struct usb_interface *intf, error_init_vars: wait_for_completion(&rtlpriv->firmware_loading_complete); + rtlpriv->cfg->ops->deinit_sw_vars(hw); error_out: rtl_deinit_core(hw); error_out2: From patchwork Thu Nov 7 13:33:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 842674 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D9C3212180 for ; Thu, 7 Nov 2024 13:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986436; cv=none; b=uPJ93FB78KOe7/KKVu5+VDOB2ojbqyecJa/4ENw9WlPL2r9SDorWdpMprD5LMjjrIZJDdCqXSWg3RTLzY7lZ4cRZZQWYL1CxpitpvTHKQxFEJoHlhS2q1SNEU3o4Vc9i5/aNg0mflR9NgJvvgcY7bDDXzuSEUknLVoAJqHg807Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986436; c=relaxed/simple; bh=eQNfJTTXuBMkIld/UqlY+MLCw44+Vjr8DRGWIIITx3A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b3RJuCuw4EnfTs/ze3i3qC5hhR3AHJdr3CWhQ62/n6/bnw00M1kV1P//5zXHbHVU2y+QqPtDaMfAuZdnB0LMthBgpV6Ic0g59JGoLa+xyJPhFctYj5CcxFp1BghPSzrXJP1lFdTtl+LG7mhyKWbcDRHZ1bIhPGh1LZQ8Pw1V0Mc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=P9xQk2d+; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="P9xQk2d+" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=aPMeNjBGCE7sdNVWDvuDbCesnkKVRkTEHukCFI1Mqdc=; b=P9xQk2d+71aBiW0Hjg6ggv5J8w zIMAwvbTgvBoAmhVd2IdyZJ5hauFWwV/hzE1eI9cbDFII0Op7YhcbV5O1/aYkMHJxfGoE9DirhQY9 6MW8XwBzql26VxrVkRQ7t2Tx9EzsteMCJmopmumCGPv1GcvbSkUx95o9MGM5FTIP9qCdE0t14at/e DGnVqYnCjMYFGjjL2rMh2kpWcAkTrPjLULKKmd71zjC/7JRWfc7XoDLPPqbmq7m0PZkuzWppgVInr 7qrRU9V4B6j0uJ+jF4Z6EO9r6TKLPolZpE0M+scZZPf4WNDkvKJm4+DN/axsBVUgjfrfyTuDuoPlF NDZY6o7Q==; Received: from 179-125-64-253-dinamico.pombonet.net.br ([179.125.64.253] helo=quatroqueijos.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t92dz-003Zsz-V8; Thu, 07 Nov 2024 14:33:52 +0100 From: Thadeu Lima de Souza Cascardo To: linux-wireless@vger.kernel.org Cc: Ping-Ke Shih , Kalle Valo , kernel-dev@igalia.com, Thadeu Lima de Souza Cascardo Subject: [PATCH net 5/5] wifi: rtlwifi: usb: fix workqueue leak when probe fails Date: Thu, 7 Nov 2024 10:33:22 -0300 Message-Id: <20241107133322.855112-6-cascardo@igalia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241107133322.855112-1-cascardo@igalia.com> References: <20241107133322.855112-1-cascardo@igalia.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 rtl_init_core creates a workqueue that is then assigned to rtl_wq. rtl_deinit_core does not destroy it. It is left to rtl_usb_deinit, which must be called in the probe error path. Fixes: 2ca20f79e0d8 ("rtlwifi: Add usb driver") Fixes: 851639fdaeac ("rtlwifi: Modify some USB de-initialize code.") Signed-off-by: Thadeu Lima de Souza Cascardo --- drivers/net/wireless/realtek/rtlwifi/usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c index 8ec687fab572..0368ecea2e81 100644 --- a/drivers/net/wireless/realtek/rtlwifi/usb.c +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c @@ -1039,6 +1039,7 @@ int rtl_usb_probe(struct usb_interface *intf, wait_for_completion(&rtlpriv->firmware_loading_complete); rtlpriv->cfg->ops->deinit_sw_vars(hw); error_out: + rtl_usb_deinit(hw); rtl_deinit_core(hw); error_out2: _rtl_usb_io_handler_release(hw);