Received: by 10.223.176.46 with SMTP id f43csp2665330wra; Mon, 22 Jan 2018 01:10:24 -0800 (PST) X-Google-Smtp-Source: AH8x226CkIPQK1xlTbLysG+sxFbbps9AxQz2oB0M+rswLzA8SXMGsiBE7HjvrIWD7+KfBhibpgb+ X-Received: by 2002:a17:902:5a41:: with SMTP id f1-v6mr3092110plm.201.1516612224843; Mon, 22 Jan 2018 01:10:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516612224; cv=none; d=google.com; s=arc-20160816; b=Y99HdRz2XvaYWdZiAW87DRFKlxhy6ThJERrYEDwNNXhgxU51PFbws04HKFB5884O9F 74nREJJFXnMZgmgEKLHAbS+pTGhrNa3BIuRayiJzWfWpfZ/jIBPF61zYda7h+CQNhEaL FOZ72NABR1yfuOjhX2AZn0+XYUCKkgxuiFEmJH3wDP2f6oqKjG0o3vyLX8hYvc6GdGPU iTJiAD4akrcOD70pTMag3tOEqxrg/5v3WJU1yCp6if+KwTzjbJciVMdx8D6MNBHi65v7 8JW5LnmsVuiGS6h6VIDK1c0H08ucJWnOPYZSRVbEbLcvAV488QDeELS/xyeZNzJihccR fYOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7sbYNiXy01+49WQp3zZHEkoujTsA7yhFxAkwmM7kLlM=; b=ZE+0fo90G4n9/4MhI/PTAhCg/nFMMBtGI5TiC0rZ2N9UEP6u792DhK0TCT1xAtGC8A Ox8wigESKZ4J8/wNmXngJon9lT7Qt280TNbKSC4Ca0fQsPSKmizL1y04RNgeIqmpAiHr r4MZG+ce9Z8oNdhHI8qUq2wsDuWZqfWywNxn1Egp3ps8pr5hK8XdMbcQBCY2QRHueOBN Bg9dqhBDlQcJgTv5qFG+K2CJdtWRYMwXC5fQoM3VfBG8c0dzPpkDv0Wd//LE0BXqWlVL gakkq9x1kNifOATdKtK052B83ha6N27WHIsZeNhJmpdq0pPzP8WmgCVgGgfkTPaGocJT LLUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5-v6si3207669pls.500.2018.01.22.01.10.10; Mon, 22 Jan 2018 01:10:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753147AbeAVIwI (ORCPT + 99 others); Mon, 22 Jan 2018 03:52:08 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33526 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753094AbeAVIwF (ORCPT ); Mon, 22 Jan 2018 03:52:05 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D5F02EFC; Mon, 22 Jan 2018 08:52:04 +0000 (UTC) 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.14 43/89] x86/apic/vector: Fix off by one in error path Date: Mon, 22 Jan 2018 09:45:23 +0100 Message-Id: <20180122083959.030994405@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083954.683903493@linuxfoundation.org> References: <20180122083954.683903493@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-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 @@ -369,8 +369,11 @@ static int x86_vector_alloc_irqs(struct irq_data->hwirq = virq + i; err = assign_irq_vector_policy(virq + i, node, data, info, irq_data); - if (err) + if (err) { + irq_data->chip_data = NULL; + free_apic_chip_data(data); goto error; + } /* * If the apic destination mode is physical, then the * effective affinity is restricted to a single target @@ -383,7 +386,7 @@ static int x86_vector_alloc_irqs(struct return 0; error: - x86_vector_free_irqs(domain, virq, i + 1); + x86_vector_free_irqs(domain, virq, i); return err; }