From: Mark Brown <broonie@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] regcache: Validate bounds of regcache drop requests
Date: Mon, 26 Oct 2026 23:32:07 +0000 [thread overview]
Message-ID: <20261026-regmap-drop-region-min-max-v1-1-2c28637ede23@kernel.org> (raw)
In-Reply-To: <20261026-regmap-drop-region-min-max-v1-0-2c28637ede23@kernel.org>
It is not valid for a caller to try to drop a range of registers from
the cache where the minimum register is greater than the maximum
register, and doing so is likely to trigger bugs in the caches. Reject
such invalid inputs.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
drivers/base/regmap/regcache.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 774e9c9bf3c4..1447967ff00b 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -589,6 +589,9 @@ int regcache_drop_region(struct regmap *map, unsigned int min,
trace_regcache_drop_region(map, min, max);
+ if (min > max)
+ return -EINVAL;
+
return map->cache_ops->drop(map, min, max);
}
EXPORT_SYMBOL_GPL(regcache_drop_region);
--
2.47.3
next prev parent reply other threads:[~2026-10-26 23:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 23:32 [PATCH 0/2] " Mark Brown
2026-10-26 23:32 ` Mark Brown [this message]
2026-10-26 23:32 ` [PATCH 2/2] regcache: Add test for bounds checking " Mark Brown
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=20261026-regmap-drop-region-min-max-v1-1-2c28637ede23@kernel.org \
--to=broonie@kernel.org \
--cc=linux-kernel@vger.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®