From nobody Mon Feb 9 19:25:57 2026 Received: from smtp84.ord1d.emailsrvr.com (smtp84.ord1d.emailsrvr.com [184.106.54.84]) (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 3D71437F8BA for ; Fri, 30 Jan 2026 17:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=184.106.54.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769792710; cv=none; b=No8jE2n9SucDUgH7t/Z3pxNJB9DbXnjrZ3k6AqD26ojXpL8OTq2qRuNUGPB/U044BXDXd91jm8801WWJx4s/FJyHAY/vF599yLKYIPJtgoBLhqHMD5+UxUTWpUq43wy+af5ilGQD0iReXrXFX2tpQhA9oGSDIm2l3U54cRkzH5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769792710; c=relaxed/simple; bh=i+GShduNbaTWAXGEOAhl55cCUyBsNKcW18AGkx5o7Sc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KaZn5zrjMnJcn4kLsY60mynx/VCHLt3P7e2TaftE398JgjLr5VW4AApCYry4+0n91xchs52rMRe6FcrW/SIk+dwHz30nfLICSY31Ornblwm+tIbjPzfLvl51rO/HDoYMdREHLT7mONUZaO6JWKKjaxiootW7EolKyQkuAGshdlg= 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=D33B3WxC; arc=none smtp.client-ip=184.106.54.84 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="D33B3WxC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mev.co.uk; s=20221208-6x11dpa4; t=1769792708; bh=i+GShduNbaTWAXGEOAhl55cCUyBsNKcW18AGkx5o7Sc=; h=From:To:Subject:Date:From; b=D33B3WxC3GIisG79EbnRxxho478pEDhRz7E5BCsbsEPSv7fFkrVwNwZztEStU4cta pVsAB+DUS7DFa/7FUkHafrrNdE3HREXnTgmzwddHsLG8Tc6KBVkCjtySIhOQyfX6Il z+G/tC25HzW2xFslooLRchN6gc9KNjKGVxGbCFKY= X-Auth-ID: abbotti@mev.co.uk Received: by smtp19.relay.ord1d.emailsrvr.com (Authenticated sender: abbotti-AT-mev.co.uk) with ESMTPSA id D08D5602FB; Fri, 30 Jan 2026 12:05:07 -0500 (EST) From: Ian Abbott To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten Subject: [PATCH 34/46] comedi: pcl726: Add sanity checks for I/O base address Date: Fri, 30 Jan 2026 16:47:59 +0000 Message-ID: <20260130170416.49994-35-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-35-1 Content-Type: text/plain; charset="utf-8" The "pcl726" driver uses an admin-supplied configuration option (`it->options[0]`) to configure the I/O port base address of various analog output ISA boards from Advantech (PCL-726/727/728) and ADLINK (ACL-6126/6128). (Most of them also have digital I/O.) It currently allows any base address to be configured but the hardware only supports base addresses (configured by on-board DIP switches) from 0 or 0x200 up to nearly 0x3FF, depending on the model. Store the minimum and maximum supported I/O address ranges in the static board information array elements (the required alignment is already stored in the `io_len` member), and add a sanity check to ensure the device is not configured at an unsupported base address. Signed-off-by: Ian Abbott --- drivers/comedi/drivers/pcl726.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/comedi/drivers/pcl726.c b/drivers/comedi/drivers/pcl72= 6.c index b542896fa0e4..d3b1f4388643 100644 --- a/drivers/comedi/drivers/pcl726.c +++ b/drivers/comedi/drivers/pcl726.c @@ -91,7 +91,8 @@ static const struct comedi_lrange *const rangelist_728[] = =3D { =20 struct pcl726_board { const char *name; - unsigned long io_len; + unsigned int io_len; + unsigned int min_io_start; unsigned int irq_mask; const struct comedi_lrange *const *ao_ranges; int ao_num_ranges; @@ -104,6 +105,7 @@ static const struct pcl726_board pcl726_boards[] =3D { { .name =3D "pcl726", .io_len =3D 0x10, + .min_io_start =3D 0x200, .ao_ranges =3D &rangelist_726[0], .ao_num_ranges =3D ARRAY_SIZE(rangelist_726), .ao_nchan =3D 6, @@ -111,6 +113,7 @@ static const struct pcl726_board pcl726_boards[] =3D { }, { .name =3D "pcl727", .io_len =3D 0x20, + .min_io_start =3D 0x200, .ao_ranges =3D &rangelist_727[0], .ao_num_ranges =3D ARRAY_SIZE(rangelist_727), .ao_nchan =3D 12, @@ -119,12 +122,14 @@ static const struct pcl726_board pcl726_boards[] =3D { }, { .name =3D "pcl728", .io_len =3D 0x08, + .min_io_start =3D 0, .ao_num_ranges =3D ARRAY_SIZE(rangelist_728), .ao_ranges =3D &rangelist_728[0], .ao_nchan =3D 2, }, { .name =3D "acl6126", .io_len =3D 0x10, + .min_io_start =3D 0x200, .irq_mask =3D 0x96e8, .ao_num_ranges =3D ARRAY_SIZE(rangelist_726), .ao_ranges =3D &rangelist_726[0], @@ -133,6 +138,7 @@ static const struct pcl726_board pcl726_boards[] =3D { }, { .name =3D "acl6128", .io_len =3D 0x08, + .min_io_start =3D 0, .ao_num_ranges =3D ARRAY_SIZE(rangelist_728), .ao_ranges =3D &rangelist_728[0], .ao_nchan =3D 2, @@ -316,7 +322,9 @@ static int pcl726_attach(struct comedi_device *dev, int ret; int i; =20 - ret =3D comedi_request_region(dev, it->options[0], board->io_len); + ret =3D comedi_check_request_region(dev, it->options[0], board->io_len, + board->min_io_start, 0x3ff, + board->io_len); if (ret) return ret; =20 --=20 2.51.0