From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x225gOCLrazaefC6ShKLV4FmSGvR3HzlxarY7to8eB9siUbbCOClxOmu0DzRqBHoAzy+xg9gh ARC-Seal: i=1; a=rsa-sha256; t=1516610950; cv=none; d=google.com; s=arc-20160816; b=woSynN1UvJiiA1V8XnlPUtNPJfmaplhV3GpyKHHqVCbu7d/xsnPAS/RaIf+oJsXmjU V5goM8Viv9a89FrdIWIvKDneB/fFpxkSDFEx2U0RuXS4D2Evapgz5eoo87bng1bzy+ir zYJA5bmx1CDhwzu7YW7mdfYkfBxuK0PxbLlNBUpXPPpu6J/E7gZ+7OhZIRSHCouz4TsR 0TYejnbclj1a385gcKvgdNm00f96kkDhyBYCRHFMPmBjOe/F91OKrb+8Qx/4Cd5INPZr RX7kNF+/P59koZvzcDcBEi9GEwto6c5PbXQl62RdTVwSvlPC8NzjdqPHWbL62eTWjYYv 1lXw== 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=kjegl3tfBQolnOFjudhVb2xfbernI+kI1zBh0tqr9I0=; b=KxLuUU4SMhY3aLhvGVYvqgzTNS4cdEjamjL38bnqqfQsTaYysowhY2n2s0ED44Pfhm KIgdZAzvmIzUxBB1qU372N2/XUMECZ2kxtE19KxDJqN/+DJqLwfYq2bZrEyqTaTMrRlA 9cvgR5CoaIU+9uA39UuLDGDgUpUK3s9tNsvjuT9dovY/wBNkZBM9i7ZOpk6C9H2Ig068 HSc363BBmmCOLQTVP1yMcAm4AuCmx118xtz/+nk8+3TOZJM7AZFup375wn2cULYgF1pW G+D1xYHrHWJemXs9XPwI8wTl5yjNHNb9+gOwQ6EegGJNs22PSvbCzaoXDWStYOZS3ETU F5cw== 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.9 22/47] x86/apic/vector: Fix off by one in error path Date: Mon, 22 Jan 2018 09:45:33 +0100 Message-Id: <20180122083927.346991073@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083925.568134913@linuxfoundation.org> References: <20180122083925.568134913@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?1590281844350217615?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.9-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 @@ -361,14 +361,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; }