Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2291749pxb; Thu, 11 Feb 2021 08:48:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGbdlq6xNC1wix6Skk3dVkNA5tqbYBZDkzvsquv3P6bNt+eT6rZVy+BPA/pi81ZsJTkHbu X-Received: by 2002:a50:b2a3:: with SMTP id p32mr2838671edd.358.1613062116346; Thu, 11 Feb 2021 08:48:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613062116; cv=none; d=google.com; s=arc-20160816; b=zrNTRDCjCk+/Z81QGt70Uzbn7IBelmSvrZeryqMuILHyXeMXubR4FNT/QPbQRgoHlg hIQeDNa84inty4sz82V5QtTrgT4TEPeNRCNZ9q3uyJAc5sDhXh8yv9IXCZoVQmmG6ROP fsR+C+oLyZAeD+i7Yc2OpCvleuGjkx/8/0z4OnZzxApSzR7SwbTxNtquGs4vIJ3TS/6j SNJ0bvYIHQ+T9IFWc9l+zBImIkRjx9zZEFSxac8t25L3OP3RYoZ5BBe32DMznycDo7ch bgaN0H9lzzOvPAS53DpiOoLDp/GBJ12QSyxTD3pRm7Mt+5Y5i7D2SRWNzX5jrAuT5i47 /oSA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0DLE2u0wCk4edyU/g7wK8Tczz5qHOlOUg6p1623eCHs=; b=d+NRbp/KbOvwrbP6sel4lPLxF+ZwSZ+X38DuQqeiJExFoVYie8iLo3/L56p0R1oP+r UQ836YLPHJ7AMBdTnHSYa+PqYjCtfaalcjkeaZczamSgxG7+2SrEcTqw9VdRmFskz8pn 9GpcLaQHFslqsbuxLdMVfypBjrl4glkYrZ1+p8iHIa/c16fO+7EE/P+mTp3gn2nXGGf8 G2nu55wSSTlWnlmYt1TiShVQAKJDnMb1gc5pjRX73OPSfwyMCO6XCuzNtGrmEE5CYzJN 1lMT38xFH/+eh+8e252IZVLuAhILooPtY3LSmUdSX8M03QsJxhSlMbuIKv4XHo8CEhoZ qXEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dbkv1IEZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si4021137eje.586.2021.02.11.08.48.11; Thu, 11 Feb 2021 08:48:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dbkv1IEZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbhBKQpK (ORCPT + 99 others); Thu, 11 Feb 2021 11:45:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:57032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231362AbhBKPhB (ORCPT ); Thu, 11 Feb 2021 10:37:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4FD1B64EFF; Thu, 11 Feb 2021 15:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613055920; bh=4Be4D8RHPbYDxfx9vGtIsxWrZ/BotuY5XFCfmyr6muc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dbkv1IEZY68AAD+L+56+/KBQduEK6IFWj+w5ciUyS0xr0KcsGMzbVffT7Wgr1c922 aGRuPCJbA0RvKxMsENNvZ4H3+p/o21w2tZ5pEvfYhck5QrruHIxa5vU+d4AbtNRl+P razqz3qnB126F3ybvGXQmPMVN2fav53O+fO/W2dI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Luca Coelho , Kalle Valo , Sasha Levin Subject: [PATCH 5.10 37/54] iwlwifi: mvm: guard against device removal in reprobe Date: Thu, 11 Feb 2021 16:02:21 +0100 Message-Id: <20210211150154.494346896@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210211150152.885701259@linuxfoundation.org> References: <20210211150152.885701259@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit 7a21b1d4a728a483f07c638ccd8610d4b4f12684 ] If we get into a problem severe enough to attempt a reprobe, we schedule a worker to do that. However, if the problem gets more severe and the device is actually destroyed before this worker has a chance to run, we use a free device. Bump up the reference count of the device until the worker runs to avoid this situation. Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/iwlwifi.20210122144849.871f0892e4b2.I94819e11afd68d875f3e242b98bef724b8236f1e@changeid Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c index cea8e397fe0f2..cb83490f1016f 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c @@ -1249,6 +1249,7 @@ static void iwl_mvm_reprobe_wk(struct work_struct *wk) reprobe = container_of(wk, struct iwl_mvm_reprobe, work); if (device_reprobe(reprobe->dev)) dev_err(reprobe->dev, "reprobe failed!\n"); + put_device(reprobe->dev); kfree(reprobe); module_put(THIS_MODULE); } @@ -1299,7 +1300,7 @@ void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error) module_put(THIS_MODULE); return; } - reprobe->dev = mvm->trans->dev; + reprobe->dev = get_device(mvm->trans->dev); INIT_WORK(&reprobe->work, iwl_mvm_reprobe_wk); schedule_work(&reprobe->work); } else if (test_bit(IWL_MVM_STATUS_HW_RESTART_REQUESTED, -- 2.27.0