From nobody Sun Apr 19 17:04:31 2026 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 13E5FCCA480 for ; Wed, 29 Jun 2022 00:02:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbiF2ACp (ORCPT ); Tue, 28 Jun 2022 20:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbiF2ACn (ORCPT ); Tue, 28 Jun 2022 20:02:43 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4F46137A1F; Tue, 28 Jun 2022 17:02:42 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2EABA153B; Tue, 28 Jun 2022 17:02:42 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C8A173F792; Tue, 28 Jun 2022 17:02:41 -0700 (PDT) From: Jeremy Linton To: linux-serial@vger.kernel.org Cc: andriy.shevchenko@linux.intel.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, miquel.raynal@bootlin.com, phil.edworthy@renesas.com, kernel@esmil.dk, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [PATCH 1/2] Revert "serial: 8250: dw: Move the USR register to pdata" Date: Tue, 28 Jun 2022 19:02:31 -0500 Message-Id: <20220629000232.3440704-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220629000232.3440704-1-jeremy.linton@arm.com> References: <20220629000232.3440704-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" pdata is only setup by DT machines, leaving ACPI machines with null pdata. Since I don't know the exact mapping of ACPI ID's to dw 8250 variations I can't add pdata to them without possibly breaking something. As such the simplest fix here is probably just to revert this commit. This reverts commit ffd381445eac2aa624e49bab5a811451e8351008. Signed-off-by: Jeremy Linton Reviewed-by: Miquel Raynal --- drivers/tty/serial/8250/8250_dw.c | 9 +++------ drivers/tty/serial/8250/8250_dwlib.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/82= 50_dw.c index f57bbd32ef11..53e488beb8c2 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -275,7 +275,7 @@ static int dw8250_handle_irq(struct uart_port *p) =20 if ((iir & UART_IIR_BUSY) =3D=3D UART_IIR_BUSY) { /* Clear the USR */ - (void)p->serial_in(p, d->pdata->usr_reg); + (void)p->serial_in(p, d->usr_reg); =20 return 1; } @@ -447,6 +447,7 @@ static void dw8250_quirks(struct uart_port *p, struct d= w8250_data *data) p->serial_out =3D dw8250_serial_outq; p->flags =3D UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; p->type =3D PORT_OCTEON; + data->usr_reg =3D OCTEON_UART_USR; data->skip_autocfg =3D true; } #endif @@ -536,6 +537,7 @@ static int dw8250_probe(struct platform_device *pdev) return -ENOMEM; =20 data->data.dma.fn =3D dw8250_fallback_dma_filter; + data->usr_reg =3D DW_UART_USR; data->pdata =3D device_get_match_data(p->dev); p->private_data =3D &data->data; =20 @@ -738,27 +740,22 @@ static const struct dev_pm_ops dw8250_pm_ops =3D { }; =20 static const struct dw8250_platform_data dw8250_dw_apb =3D { - .usr_reg =3D DW_UART_USR, }; =20 static const struct dw8250_platform_data dw8250_octeon_3860_data =3D { - .usr_reg =3D OCTEON_UART_USR, .quirks =3D DW_UART_QUIRK_OCTEON, }; =20 static const struct dw8250_platform_data dw8250_armada_38x_data =3D { - .usr_reg =3D DW_UART_USR, .quirks =3D DW_UART_QUIRK_ARMADA_38X, }; =20 static const struct dw8250_platform_data dw8250_renesas_rzn1_data =3D { - .usr_reg =3D DW_UART_USR, .cpr_val =3D 0x00012f32, .quirks =3D DW_UART_QUIRK_IS_DMA_FC, }; =20 static const struct dw8250_platform_data dw8250_starfive_jh7100_data =3D { - .usr_reg =3D DW_UART_USR, .quirks =3D DW_UART_QUIRK_SKIP_SET_RATE, }; =20 diff --git a/drivers/tty/serial/8250/8250_dwlib.h b/drivers/tty/serial/8250= /8250_dwlib.h index 055bfdc87985..9870ad0d54e4 100644 --- a/drivers/tty/serial/8250/8250_dwlib.h +++ b/drivers/tty/serial/8250/8250_dwlib.h @@ -26,7 +26,6 @@ struct dw8250_port_data { }; =20 struct dw8250_platform_data { - u8 usr_reg; u32 cpr_val; unsigned int quirks; }; @@ -35,6 +34,7 @@ struct dw8250_data { struct dw8250_port_data data; const struct dw8250_platform_data *pdata; =20 + u8 usr_reg; int msr_mask_on; int msr_mask_off; struct clk *clk; --=20 2.35.1 From nobody Sun Apr 19 17:04:31 2026 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 E718DC433EF for ; Wed, 29 Jun 2022 00:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229564AbiF2ACv (ORCPT ); Tue, 28 Jun 2022 20:02:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbiF2ACn (ORCPT ); Tue, 28 Jun 2022 20:02:43 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1C21937A23; Tue, 28 Jun 2022 17:02:43 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1E5A81691; Tue, 28 Jun 2022 17:02:43 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AEEE63F792; Tue, 28 Jun 2022 17:02:42 -0700 (PDT) From: Jeremy Linton To: linux-serial@vger.kernel.org Cc: andriy.shevchenko@linux.intel.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, miquel.raynal@bootlin.com, phil.edworthy@renesas.com, kernel@esmil.dk, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [PATCH 2/2] serial: 8250: dw: Fix NULL pointer dereference Date: Tue, 28 Jun 2022 19:02:32 -0500 Message-Id: <20220629000232.3440704-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220629000232.3440704-1-jeremy.linton@arm.com> References: <20220629000232.3440704-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Similarly to e6a08c6949cb, ACPI machines don't have a pdata setup, leading to a null pointer dereference when dw8250_handle_irq runs. Fixes: aa63d786cea2 ("serial: 8250: dw: Add support for DMA flow controllin= g devices") Signed-off-by: Jeremy Linton Reviewed-by: Miquel Raynal --- drivers/tty/serial/8250/8250_dw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/82= 50_dw.c index 53e488beb8c2..06f80090cbb9 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -237,10 +237,13 @@ static int dw8250_handle_irq(struct uart_port *p) struct dw8250_data *d =3D to_dw8250_data(p->private_data); unsigned int iir =3D p->serial_in(p, UART_IIR); bool rx_timeout =3D (iir & 0x3f) =3D=3D UART_IIR_RX_TIMEOUT; - unsigned int quirks =3D d->pdata->quirks; + unsigned int quirks =3D 0; unsigned int status; unsigned long flags; =20 + if (d->pdata) + quirks =3D d->pdata->quirks; + /* * There are ways to get Designware-based UARTs into a state where * they are asserting UART_IIR_RX_TIMEOUT but there is no actual --=20 2.35.1