From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68BFCE95A99 for ; Mon, 9 Oct 2023 13:49:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377470AbjJINtY (ORCPT ); Mon, 9 Oct 2023 09:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377703AbjJINtI (ORCPT ); Mon, 9 Oct 2023 09:49:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6133B94 for ; Mon, 9 Oct 2023 06:49:07 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A33BEC433C7; Mon, 9 Oct 2023 13:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696859347; bh=3Hq8aUGcNX9n1Cr5O48scm+3ppeitdCc41Whjwi0YvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nXn8OSAalFiWAKBgiwT9jTFscM/KnORNDE+XjzlbvES7CwEhIbEb1FNIcrlXnMa3r Xb4oykYrWWSkNzmlIP+9Yx9tnv8i4YWSp0FxiYateeeje4HdJdujkull9TekHtQa7X ZmVkGtmoeeknV8PTuInOowOl7FMb858m7kqsD4YU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Andy Shevchenko , Florian Fainelli Subject: [PATCH 4.14 22/55] serial: 8250_port: Check IRQ data before use Date: Mon, 9 Oct 2023 15:06:21 +0200 Message-ID: <20231009130108.559651966@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009130107.717692466@linuxfoundation.org> References: <20231009130107.717692466@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andy Shevchenko commit cce7fc8b29961b64fadb1ce398dc5ff32a79643b upstream. In case the leaf driver wants to use IRQ polling (irq = 0) and IIR register shows that an interrupt happened in the 8250 hardware the IRQ data can be NULL. In such a case we need to skip the wake event as we came to this path from the timer interrupt and quite likely system is already awake. Without this fix we have got an Oops: serial8250: ttyS0 at I/O 0x3f8 (irq = 0, base_baud = 115200) is a 16550A ... BUG: kernel NULL pointer dereference, address: 0000000000000010 RIP: 0010:serial8250_handle_irq+0x7c/0x240 Call Trace: ? serial8250_handle_irq+0x7c/0x240 ? __pfx_serial8250_timeout+0x10/0x10 Fixes: 0ba9e3a13c6a ("serial: 8250: Add missing wakeup event reporting") Cc: stable Signed-off-by: Andy Shevchenko Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20230831222555.614426-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_port.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1911,7 +1911,10 @@ int serial8250_handle_irq(struct uart_po skip_rx = true; if (status & (UART_LSR_DR | UART_LSR_BI) && !skip_rx) { - if (irqd_is_wakeup_set(irq_get_irq_data(port->irq))) + struct irq_data *d; + + d = irq_get_irq_data(port->irq); + if (d && irqd_is_wakeup_set(d)) pm_wakeup_event(tport->tty->dev, 0); if (!up->dma || handle_rx_dma(up, iir)) status = serial8250_rx_chars(up, status);