Received: by 2002:a05:6520:1682:b0:147:d1a0:b502 with SMTP id ck2csp5598038lkb; Mon, 11 Oct 2021 09:40:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyphBINIf0cshrk+FkOxPbgYKkicx0SIeAVhqAqNc41Y+Zi2fg3EHvwkq6o6BHgadc/9nDq X-Received: by 2002:a50:9d8a:: with SMTP id w10mr43904081ede.163.1633970436368; Mon, 11 Oct 2021 09:40:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633970436; cv=none; d=google.com; s=arc-20160816; b=RgEOIYpEbcWH/8Uy+PpZ+5T2BF6E6uUjzq4E4KGnEU8mEcRqVt1fx/HWpLzIPt4Q7R HfPNF2Z5DYZVL2jrNAz7F7B/b3T4RfQnCa4diRLW5jaqZ2vmjrtKEEdQmUWs/TBr75+R yFuhGz5B59VhXs4efkcj9H9i9SUySwVsbChiw5HSfeiJs7+N0tUXkFRUIVVJJQRlDUhr 5aYo/vIKtnEDZTZdw+shSe953Mt1/Zp+GFlZfljbc3qVeZ5pRJ7bYAww8nvwkLqta2iN 52Txn8NyllCXqBz97Fz0+v6DwrwmKk/X+7E3zr/LzXqHV45FQkRmmzmokjcUQrgk5GF7 69OA== 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=5WdNo3EkLoXR7LqZX6/MhHbn6l2+5I456Gqc4OWzzqQ=; b=CtrIgLL6ewxLW/gKcDvWjxjTxjqYMKfPy6ubqvo9dXN4pPhc1rY4fb91eQyaDssmjX pZ3bc+rwpt+xA1Kmqm9omFr3NWxY7ahlzKJUlxvv3zoWlLaltvcnyj0HR3JLYtQrVKSH 2dvam1TGwM2eV9soFO0F8+u2mSONBYdlsXmOo34bF1I9n6ysXghBnr38CcAiG0lhqqR0 /y4uhStLdh/fQu9PiqDrv/iyN6x5DTHyF1Dv0PYpBMC5ggCvH4Bv/ptnRU3GiM18ZoBh W7xE1+IzeJA+SdpG7+WZbp2Qz/uwKn1kSp95PqNEd8endrY9KZOj4QtE7xL8AinLYKXm e17A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zlg+4F6+; 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 h20si11796058ejc.757.2021.10.11.09.40.13; Mon, 11 Oct 2021 09:40:36 -0700 (PDT) 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=Zlg+4F6+; 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 S244750AbhJKOSQ (ORCPT + 99 others); Mon, 11 Oct 2021 10:18:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:38796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244418AbhJKOPf (ORCPT ); Mon, 11 Oct 2021 10:15:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B376260EFE; Mon, 11 Oct 2021 14:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633961133; bh=JPJMOcFtEqx+xJsxvLHnps4mvqsleOwByZ9JRRRwcI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zlg+4F6+R9CyIz8l0QSVZTo8s4HA8jks0HEfevZaiY2a/qGtJ6w++xSbN8WUeFDZQ CT+xpB/uka/4K5B/ADcz3bPZESrcOyTtSkBDLYZ6fZpvfpHrh3ko4/K2n7hvCXwGzJ VY4HKb+FrzlmBdkQ9kZOC34h0MO3o3+9QTCt0X5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, PJ Waskiewicz , Sylwester Dziedziuch , Mateusz Palczewski , Dave Switzer , Tony Nguyen , Sasha Levin Subject: [PATCH 4.19 25/28] i40e: Fix freeing of uninitialized misc IRQ vector Date: Mon, 11 Oct 2021 15:47:15 +0200 Message-Id: <20211011134641.529909977@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134640.711218469@linuxfoundation.org> References: <20211011134640.711218469@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: Sylwester Dziedziuch [ Upstream commit 2e5a20573a926302b233b0c2e1077f5debc7ab2e ] When VSI set up failed in i40e_probe() as part of PF switch set up driver was trying to free misc IRQ vectors in i40e_clear_interrupt_scheme and produced a kernel Oops: Trying to free already-free IRQ 266 WARNING: CPU: 0 PID: 5 at kernel/irq/manage.c:1731 __free_irq+0x9a/0x300 Workqueue: events work_for_cpu_fn RIP: 0010:__free_irq+0x9a/0x300 Call Trace: ? synchronize_irq+0x3a/0xa0 free_irq+0x2e/0x60 i40e_clear_interrupt_scheme+0x53/0x190 [i40e] i40e_probe.part.108+0x134b/0x1a40 [i40e] ? kmem_cache_alloc+0x158/0x1c0 ? acpi_ut_update_ref_count.part.1+0x8e/0x345 ? acpi_ut_update_object_reference+0x15e/0x1e2 ? strstr+0x21/0x70 ? irq_get_irq_data+0xa/0x20 ? mp_check_pin_attr+0x13/0xc0 ? irq_get_irq_data+0xa/0x20 ? mp_map_pin_to_irq+0xd3/0x2f0 ? acpi_register_gsi_ioapic+0x93/0x170 ? pci_conf1_read+0xa4/0x100 ? pci_bus_read_config_word+0x49/0x70 ? do_pci_enable_device+0xcc/0x100 local_pci_probe+0x41/0x90 work_for_cpu_fn+0x16/0x20 process_one_work+0x1a7/0x360 worker_thread+0x1cf/0x390 ? create_worker+0x1a0/0x1a0 kthread+0x112/0x130 ? kthread_flush_work_fn+0x10/0x10 ret_from_fork+0x1f/0x40 The problem is that at that point misc IRQ vectors were not allocated yet and we get a call trace that driver is trying to free already free IRQ vectors. Add a check in i40e_clear_interrupt_scheme for __I40E_MISC_IRQ_REQUESTED PF state before calling i40e_free_misc_vector. This state is set only if misc IRQ vectors were properly initialized. Fixes: c17401a1dd21 ("i40e: use separate state bit for miscellaneous IRQ setup") Reported-by: PJ Waskiewicz Signed-off-by: Sylwester Dziedziuch Signed-off-by: Mateusz Palczewski Tested-by: Dave Switzer Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 8f7d3af75ed6..062b94251782 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -4724,7 +4724,8 @@ static void i40e_clear_interrupt_scheme(struct i40e_pf *pf) { int i; - i40e_free_misc_vector(pf); + if (test_bit(__I40E_MISC_IRQ_REQUESTED, pf->state)) + i40e_free_misc_vector(pf); i40e_put_lump(pf->irq_pile, pf->iwarp_base_vector, I40E_IWARP_IRQ_PILE_ID); -- 2.33.0