From nobody Thu Apr 2 13:14:05 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 1BB4FC07E9D for ; Fri, 23 Sep 2022 18:52:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbiIWSwN (ORCPT ); Fri, 23 Sep 2022 14:52:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiIWSwL (ORCPT ); Fri, 23 Sep 2022 14:52:11 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 86FCF121119 for ; Fri, 23 Sep 2022 11:52:09 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id B959792009C; Fri, 23 Sep 2022 20:52:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id B226892009B; Fri, 23 Sep 2022 19:52:08 +0100 (BST) Date: Fri, 23 Sep 2022 19:52:08 +0100 (BST) From: "Maciej W. Rozycki" To: Sudip Mukherjee cc: Bjorn Helgaas , linux-kernel@vger.kernel.org Subject: [PATCH] parport_pc: Avoid FIFO port location truncation Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Match the data type of a temporary holding a reference to the FIFO port=20 with the type of the original reference coming from `struct parport',=20 avoiding data truncation with LP64 ports such as SPARC64 that refer to=20 PCI port I/O locations via their corresponding MMIO addresses and will=20 therefore have non-zero bits in the high 32-bit part of the reference. And in any case it is cleaner to have the data types matching here. Signed-off-by: Maciej W. Rozycki Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Link: https://lore.kernel.org/linux-pci/20220419033752.GA1101844@bhelgaas/ Acked-by: Sudip Mukherjee --- Hi, Found by code inspection in tracking down the cause of an oops; cf.=20 . =20 Credit to Bjorn for the details of the SPARC64 peculiarity. I guess nobody has actually ever used a PCI parallel port with a SPARC64=20 machine, so it's probably not worth backporting, but I have chosen to add=20 a `Fixes' tag regardless for tracking, statistics, or whatever it might be=20 useful for, even though the offending temporary has been added long before=20 our GIT history (with or around Linux 2.3.10 AFAICT). Maciej --- drivers/parport/parport_pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) linux-parport-pc-fifo-unsigned-long.diff Index: linux-macro/drivers/parport/parport_pc.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- linux-macro.orig/drivers/parport/parport_pc.c +++ linux-macro/drivers/parport/parport_pc.c @@ -468,7 +468,7 @@ static size_t parport_pc_fifo_write_bloc const unsigned char *bufp =3D buf; size_t left =3D length; unsigned long expire =3D jiffies + port->physport->cad->timeout; - const int fifo =3D FIFO(port); + const unsigned long fifo =3D FIFO(port); int poll_for =3D 8; /* 80 usecs */ const struct parport_pc_private *priv =3D port->physport->private_data; const int fifo_depth =3D priv->fifo_depth;