Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2850342rwl; Thu, 13 Apr 2023 11:43:13 -0700 (PDT) X-Google-Smtp-Source: AKy350b6WW4G+wGgtFasXKvy9z7xc7qS4fhPHBdBDRNLoslW9NY53HeuCnKH4iXcX0MZzbENO+D/ X-Received: by 2002:a05:6a00:1703:b0:635:1d57:bdee with SMTP id h3-20020a056a00170300b006351d57bdeemr5482075pfc.11.1681411392797; Thu, 13 Apr 2023 11:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681411392; cv=none; d=google.com; s=arc-20160816; b=op+7IyBBJO488aeSDoIZfiYUrR0PSCMZLSHH2/gkyxEllAQC95/J+ycl15gfKPUB4A 9CclvoRZKioa/ZSJIWOCbQJ0uVILhVAZ1INUKdfGEP+MCkw1OOniHyK0QtGy7+8WQBeP xQlCFqhRso7OsDzybVbWoB4Q49drT8KpmmmNxYlDUR1mN12EyU6+Z3Eytc2fQmN5eacW 1yYJEoX/17nsBQQCZhvoexOfjD9FlSzbFHhKZEZU2CObI6HRRHa9nvl2Kiea5+qOQB01 fNxoMvg1Z0JCRPZZUbvUK7rhDPOSfBwNu+qgMxmC6ovKdmyXObrvouOlcUD2uhUcaKjI HrZQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rGb1ihU/3ZYL+upjcVu0MZNsAW3UgNMlH8FeDTikUwM=; b=FMBkSNmAbvfMWEV8QM34LtP1E7kLdXgQVAZuPI1rWKCo+tpwDtCsmrT+PgxWsxIdbS YQbslihAgAz9uLl9+6sTSHbsLwTWunxEyCvrufH7Uu5DaARF+VJ7aMJLvCHL5xpADSTf YGGljp026PjBMnT5g2G/8DWGnzvdR6l9tzh44DTUWES/GS6lTRSRTeYmZdQlGEjl0IVV HTuNqQOXO1m0AeFD4BpswziBgqqoOKWAQl89zArOgBeIHTgwLVsVIDhu9JoZEwW/gcno V5dlSLR4XHq/XZwUGnBFcCZpQcD5muNL7OsdFlnI8+ED7FE7Wzr+g0n2AaK0D1NwoNMA 7kXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=f3KwOmgr; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h30-20020a056a00001e00b0063b63077b05si246421pfk.386.2023.04.13.11.43.04; Thu, 13 Apr 2023 11:43:12 -0700 (PDT) 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=@intel.com header.s=Intel header.b=f3KwOmgr; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbjDMSmY (ORCPT + 61 others); Thu, 13 Apr 2023 14:42:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbjDMSmX (ORCPT ); Thu, 13 Apr 2023 14:42:23 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CB0E6599 for ; Thu, 13 Apr 2023 11:42:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681411329; x=1712947329; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qK4ZJnVXZHIf+ARZwnesw+Jpu0/SzUy2QsZlZCy9AJc=; b=f3KwOmgrJ/+9Zxq+CvCMfl4aHJUjQ4EBbIKYaDvl/s887xcN37IsyKBz eiUHtLqa60Vj/1QnE99f+qF58WwOL85puyPW1j8aKHGwHF+wlqVI1Pzht SvAaD7ErDt2irCN9LoMxegvbT2XymtrTO31CIR0nhASOXADPJS3/T+PLV 1teqKGWryoTdwyOgLixiTcErwp4AQWch3PXeXhBSJ896PWw4VnxxYBwo+ 9L8aBcFoopKVmdBRbZgVUtFhqx7jAYSWtsPt2Oy2fpVJ0o4gTHomN7iZJ 2zAM9c8Hocj7Abl0cyMB5Bmr1ojJOD2bi/MBODAr5lOAd2kIlEeYQzIdg Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="372127091" X-IronPort-AV: E=Sophos;i="5.99,194,1677571200"; d="scan'208";a="372127091" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 11:41:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10679"; a="719984424" X-IronPort-AV: E=Sophos;i="5.99,194,1677571200"; d="scan'208";a="719984424" Received: from apeled2-mobl.ger.corp.intel.com (HELO ggreenma-mobl2.lan) ([10.251.184.75]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2023 11:41:16 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Daniel Gabay , Gregory Greenman Subject: [PATCH 12/15] wifi: iwlwifi: pcie: fix possible NULL pointer dereference Date: Thu, 13 Apr 2023 21:40:32 +0300 Message-Id: <20230413213309.082f6e21341b.I0db21d7fa9a828d571ca886713bd0b5d0b6e1e5c@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230413184035.1140892-1-gregory.greenman@intel.com> References: <20230413184035.1140892-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED 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 From: Daniel Gabay It is possible that iwl_pci_probe() will fail and free the trans, then afterwards iwl_pci_remove() will be called and crash by trying to access trans which is already freed, fix it. iwlwifi 0000:01:00.0: Detected crf-id 0xa5a5a5a2, cnv-id 0xa5a5a5a2 wfpm id 0xa5a5a5a2 iwlwifi 0000:01:00.0: Can't find a correct rfid for crf id 0x5a2 ... BUG: kernel NULL pointer dereference, address: 0000000000000028 ... RIP: 0010:iwl_pci_remove+0x12/0x30 [iwlwifi] pci_device_remove+0x3e/0xb0 device_release_driver_internal+0x103/0x1f0 driver_detach+0x4c/0x90 bus_remove_driver+0x5c/0xd0 driver_unregister+0x31/0x50 pci_unregister_driver+0x40/0x90 iwl_pci_unregister_driver+0x15/0x20 [iwlwifi] __exit_compat+0x9/0x98 [iwlwifi] __x64_sys_delete_module+0x147/0x260 Signed-off-by: Daniel Gabay Signed-off-by: Gregory Greenman --- drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c index 70f6c59eec5d..a60329079167 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c @@ -1733,6 +1733,9 @@ static void iwl_pci_remove(struct pci_dev *pdev) { struct iwl_trans *trans = pci_get_drvdata(pdev); + if (!trans) + return; + iwl_drv_stop(trans->drv); iwl_trans_pcie_free(trans); -- 2.38.1