From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227bVpgFD2u6Gmy8S28MNJTfo9cHwSC2+Y6o10N4B5wQTKgkw5/I9s0QehtEVZI2/zV0lBgT ARC-Seal: i=1; a=rsa-sha256; t=1516611126; cv=none; d=google.com; s=arc-20160816; b=rdaWfQDjQ5jPMVAnc7QlMqGVmgLEs1lduTnRjCcwizfCodjVZwix6nLWWexLdhGeN9 q1Rms65jORyTcNmzI1YiGjw88Nzdyx7jed3WdNHEww8eBywOMcb7s3xum8Ta4e1ck0Ml ai8MOAuCKgNTBwrWYrHJSYF0KpJ93TIUwIFQscCfKywY5Iv0K7dxaa63RVHR5viA5nm0 czFa0LcCFWtaEpaQSBiIr/aM4YxkIY8aff8VqcPZxhp2sFw+pDe7zGIJLPtVwIgmALEH 0pat1lpLTO+ljB9millZizRHCHzdYgxpiARsN+Jedkio4I4brY5wr1s8FXbN+3fqUO6d zaSw== 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=7sbYNiXy01+49WQp3zZHEkoujTsA7yhFxAkwmM7kLlM=; b=TJtadBno80UtwWhHZHVDdRuaFZ53dI5BgeEyIalizm2w5mVGgWSb2RwYYM8g8MHjSd uDr7xj/5qHmvlKVpQfE8aBoR6j3w1zRwJjeGmjp/iqQffpsmKzIRoDM7BlvgztRnkOOJ d9rEHOeNKT9iGrOqULAu9JzXJF/DIGFovfSmRh8cT11B1WPrzyc+U/myWbYzGKh4hmOD AfxN2ggzrN0rihiwt/4UwldVszlDucouw3kngJEaeYGS7GtRjLCJtYIF82CD13ZQXQgU Kh79MfJASTbFAv1Dv0yuMDKTBQnD6ngTOZFKrbl0ZZuAd2wkSrQsCBWh06v7ImPsXdie S+cQ== 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.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 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?1590282028917083227?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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; }