From nobody Mon Feb 9 17:23:18 2026 Received: from smtp85.ord1d.emailsrvr.com (smtp85.ord1d.emailsrvr.com [184.106.54.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCFC2341660 for ; Fri, 30 Jan 2026 17:11:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=184.106.54.85 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769793109; cv=none; b=gxeLTYwBCMzp6ajOJ/tB+R3ToGKYhzNWtufRUTnHYLUzT6YYHb1NPHYtRyihbCVNBME53uRdP/teabya/nzzT5oLzpWhsMRLDqDtZHmF/Lvz+aALn0Ns8tsWXGojvWfhqHoF8vrFelogK31znQm+08tRgFx7PHelksIz44uAZ44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769793109; c=relaxed/simple; bh=kvA7p+XyHKaMB2UvsSnq65o+jjv1uAVi7tml7HL5pyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ywaf06a3ySHjf1v5EIgOwm0Zffj1MlWYR1qqpq3xoTz8/3P1vmJo+5W5GMN6BAAEHoxc4vH1jf/ZPW5L37SyqStb7Vd+k3VUGi402ZnnXXtAzY3UKoKSYxsuVLKdLvdv78TC1qXpdhr8JsGbYbq43K8UsOH/K0TewMcCzZfdJA0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mev.co.uk; spf=pass smtp.mailfrom=mev.co.uk; dkim=pass (1024-bit key) header.d=mev.co.uk header.i=@mev.co.uk header.b=RggzKLUt; arc=none smtp.client-ip=184.106.54.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mev.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mev.co.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mev.co.uk header.i=@mev.co.uk header.b="RggzKLUt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1769792673; bh=kvA7p+XyHKaMB2UvsSnq65o+jjv1uAVi7tml7HL5pyY=; h=From:To:Subject:Date:From; b=RggzKLUtX4Xc+A82ZcNNE0iP4YJ7zJenwL0gnRuoWFxsu4uA3CZPrUstFKwl+zSFV 4+ZFSf8W0RAdcTekAcTELTk8nOeeSQ8LT5/yAnltQYm8tXs3bAw243re+uzE84GQ2H S3ke6PKjNO24bkdXHt8FTvET/JuV1289KC1nR8kI= X-Auth-ID: abbotti@mev.co.uk Received: by smtp19.relay.ord1d.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id 4371E602B8; Fri, 30 Jan 2026 12:04:32 -0500 (EST) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten Subject: [PATCH 02/46] comedi: 8255: Add some I/O base address sanity checks Date: Fri, 30 Jan 2026 16:47:27 +0000 Message-ID: <20260130170416.49994-3-abbotti@mev.co.uk> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260130170416.49994-1-abbotti@mev.co.uk> References: <20260130170416.49994-1-abbotti@mev.co.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Classification-ID: 429d5722-7f90-4557-8586-08913fa85e9e-3-1 Content-Type: text/plain; charset="utf-8" The "8255" driver allows a COMEDI device to be constructed from one or more 8255 chips, each at an I/O port base address specified by the admin-supplied configuration options (`it->options[]`). Currently, the driver allows any I/O base addresses to be specified as long as the I/O regions can be reserved, and it converts the specified `int` option values holding the base address to `unsigned long`. It doesn't make sense to allow base addresses that are not aligned to 4-byte boundaries because the hardware register addresses would not be decoded properly, so add a check for valid alignment. Convert the option values that specify the base addresses from `int` to `unsigned int` instead of `unsigned long` so they end up the same on 32-bit and 64-bit systems. Signed-off-by: Ian Abbott --- drivers/comedi/drivers/8255.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/comedi/drivers/8255.c b/drivers/comedi/drivers/8255.c index 5f70938b4477..ff45248ebb29 100644 --- a/drivers/comedi/drivers/8255.c +++ b/drivers/comedi/drivers/8255.c @@ -47,7 +47,7 @@ static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; - unsigned long iobase; + unsigned int iobase; int ret; int i; =20 @@ -70,13 +70,15 @@ static int dev_8255_attach(struct comedi_device *dev, iobase =3D it->options[i]; =20 /* - * __comedi_request_region() does not set dev->iobase. + * __comedi_check_request_region() does not set dev->iobase. * * For 8255 devices that are manually attached using * comedi_config, the 'iobase' is the actual I/O port - * base address of the chip. + * base address of the chip. It should be aligned on + * a 4-byte boundary. */ - ret =3D __comedi_request_region(dev, iobase, I8255_SIZE); + ret =3D __comedi_check_request_region(dev, iobase, I8255_SIZE, + 0, UINT_MAX, 4); if (ret) return ret; ret =3D subdev_8255_io_init(dev, s, iobase); --=20 2.51.0