From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227UklbTecAnjF4OrAuT/7Za8nG+sCTgMdl0M8Lrcny7e4RMfAbpbHQehCwt1PA1+swN6fNp ARC-Seal: i=1; a=rsa-sha256; t=1516610583; cv=none; d=google.com; s=arc-20160816; b=KA+n2VbsZW2X2+5SnFbxhIx35j8r/dcw/uUWNVghby0gy14eU+qj9BWIlq5NkDZ9pG OnJl7sUg3IoKo37vTGQN2fvdVfSEj4UbnvKmhbqoqHlTZjLuS53/+ojJvBXJQopc/NVM MgYa90RAkSs8Jv1u7n+CbFHxWGUzJ4XiJ/mOg+rG/5l2z+mTkC8nhovIIpV6ynV0j9VB N8Inea1datciQm16uYx4B29OLYfZLV5/8q5Zx2YPT9l7cUCnro/9et8N6yUaq3yg9UU8 mF7TlrrMwQhetTGzTi07ppXqNgUcVxo00poheLELSbD6gYt4266IohWtEBG0xglvDOgE ndBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=40UoORHHVwa7L1RizC/NSSQBwLoz81ujiltU0TR8WoM=; b=RrLyRsa5MVokDp48NivPmF2k6v6iYMz8GARZSwovmE08no64VFoKp+wQG7nClKygry n25+/fqmo0HF6FSGHEsjkKjcQIps0F2L/XfI2LeSrp4//mWBe1NGaQ6wsG42gbALB3jC f1ccllEdF47iunWIL7rqfCEjH9h8TPtNl7MkwzWbCdQK6FJ/36RT+XNU7lUfOFj3d8zK EQcfDEFDctU5P1IZT5nsrNcz85IOLjgqLpI8NodCiVn3mkF7LxGn80/hkfw5DvyfcTfG Zgtz3vOjUYJYZxEPJ0462iQtOThwPmOA8dX1xIDXxYn+Ia5wXye3gfqr80kYqkyxLD4/ tpHw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Keith Busch , Thomas Gleixner Subject: [PATCH 4.4 33/53] x86/apic/vector: Fix off by one in error path Date: Mon, 22 Jan 2018 09:40:25 +0100 Message-Id: <20180122083911.776154720@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083910.299610926@linuxfoundation.org> References: <20180122083910.299610926@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590281458787974242?= X-GMAIL-MSGID: =?utf-8?q?1590281458787974242?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit 45d55e7bac4028af93f5fa324e69958a0b868e96 upstream. Keith reported the following warning: WARNING: CPU: 28 PID: 1420 at kernel/irq/matrix.c:222 irq_matrix_remove_managed+0x10f/0x120 x86_vector_free_irqs+0xa1/0x180 x86_vector_alloc_irqs+0x1e4/0x3a0 msi_domain_alloc+0x62/0x130 The reason for this is that if the vector allocation fails the error handling code tries to free the failed vector as well, which causes the above imbalance warning to trigger. Adjust the error path to handle this correctly. Fixes: b5dc8e6c21e7 ("x86/irq: Use hierarchical irqdomain to manage CPU interrupt vectors") Reported-by: Keith Busch Signed-off-by: Thomas Gleixner Tested-by: Keith Busch Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801161217300.1823@nanos Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/apic/vector.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -359,14 +359,17 @@ static int x86_vector_alloc_irqs(struct irq_data->chip_data = data; irq_data->hwirq = virq + i; err = assign_irq_vector_policy(virq + i, node, data, info); - if (err) + if (err) { + irq_data->chip_data = NULL; + free_apic_chip_data(data); goto error; + } } return 0; error: - x86_vector_free_irqs(domain, virq, i + 1); + x86_vector_free_irqs(domain, virq, i); return err; }