From: Danish Khateeb <danishkhateeb03@gmail.com>
To: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Linus Walleij <linusw@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>,
Bamvor Jian Zhang <bamv2005@gmail.com>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Samuel Moelius <sam.moelius@trailofbits.com>,
linux-gpio@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
Danish Khateeb <danishkhateeb03@gmail.com>
Subject: [PATCH 2/2] selftests: gpio: expect gpio-mockup to reject a range with no lines
Date: Wed, 30 Sep 2026 21:16:09 -0500 [thread overview]
Message-ID: <20261001021609.167505-2-danishkhateeb03@gmail.com> (raw)
In-Reply-To: <20261001021609.167505-1-danishkhateeb03@gmail.com>
Since commit 446e8c31d0fc ("gpio: mockup: reject invalid
gpio_mockup_ranges widths"), gpio-mockup refuses to load when a range
has no lines. The "no lines defined" case of gpio-mockup.sh still
expects gpio_mockup_ranges=0,0 to load and create no chip, so the test
now fails there:
# 2. Module load error tests
# 2.1 no lines defined
# test failed: insert gpio-mockup failed with error 1
# GPIO gpio-mockup test FAIL
Check that the module rejects that range instead.
Fixes: 446e8c31d0fc ("gpio: mockup: reject invalid gpio_mockup_ranges widths")
Assisted-by: LLM
Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>
---
Notes:
Tested on v7.3-rc5 (x86_64, KASAN and lockdep, virtme-ng):
- before: gpio-mockup.sh fails at 2.1, both by default and with -f.
- after: it passes by default, with -f, and with -t cdev_v1 and
-f -t cdev_v1 (on a GPIO_CDEV_V1=y kernel).
- control: with "-1,32" in place of "0,0", the new check fails with
"insert gpio-mockup with ranges <-1,32> did not fail".
tools/testing/selftests/gpio/gpio-mockup.sh | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/gpio/gpio-mockup.sh b/tools/testing/selftests/gpio/gpio-mockup.sh
index fc2dd4c24d06..41c8a1c1502e 100755
--- a/tools/testing/selftests/gpio/gpio-mockup.sh
+++ b/tools/testing/selftests/gpio/gpio-mockup.sh
@@ -310,6 +310,16 @@ insmod_test()
remove_module || fail "failed to remove module with error $?"
}
+# Load the module with the given ranges and check that it is rejected.
+insmod_fail_test()
+{
+ local ranges=$1
+
+ if modprobe -q $module "gpio_mockup_ranges=$ranges"; then
+ fail "insert $module with ranges <$ranges> did not fail"
+ fi
+}
+
while getopts ":frvt:" opt; do
case $opt in
f)
@@ -378,7 +388,7 @@ if [ "$full_test" ]; then
fi
echo "2. Module load error tests"
echo "2.1 no lines defined"
-insmod_test "0,0"
+insmod_fail_test "0,0"
if [ "$full_test" ]; then
echo "2.2 ignore range overlap"
insmod_test "0,32,0,1" 32
--
2.55.0
prev parent reply other threads:[~2026-10-01 2:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 2:16 [PATCH 1/2] selftests: gpio: enable GPIO_CDEV_V1 for gpio-cdev-uaf Danish Khateeb
2026-10-01 2:16 ` Danish Khateeb [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261001021609.167505-2-danishkhateeb03@gmail.com \
--to=danishkhateeb03@gmail.com \
--cc=bamv2005@gmail.com \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=sam.moelius@trailofbits.com \
--cc=shuah@kernel.org \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®