From: Andrew Scull <ascull@google.com>
To: u-boot@lists.denx.de
Cc: sjg@chromium.org, seanga2@gmail.com,
Andrew Scull <ascull@google.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Jean-Jacques Hiblot <jjhiblot@ti.com>,
Pratyush Yadav <p.yadav@ti.com>
Subject: [PATCH 7/8] test: Fix pointer overrun in dm_test_devm_regmap()
Date: Sun, 3 Apr 2022 10:39:14 +0000 [thread overview]
Message-ID: <20220403103915.3338027-8-ascull@google.com> (raw)
In-Reply-To: <20220403103915.3338027-1-ascull@google.com>
This tests calls regmap_read() which takes a uint pointer as an output
parameter. The test was passing a pointer to a u16 which resulted in an
overflow when the output was written. Fix this by following the
regmap_read() API and passing a uint pointer instead.
Signed-off-by: Andrew Scull <ascull@google.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Jean-Jacques Hiblot <jjhiblot@ti.com>
Cc: Pratyush Yadav <p.yadav@ti.com>
---
test/dm/regmap.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/test/dm/regmap.c b/test/dm/regmap.c
index 04bb1645d1..8560f2afc2 100644
--- a/test/dm/regmap.c
+++ b/test/dm/regmap.c
@@ -286,8 +286,7 @@ U_BOOT_DRIVER(regmap_test) = {
static int dm_test_devm_regmap(struct unit_test_state *uts)
{
int i = 0;
- u16 val;
- void *valp = &val;
+ uint val;
u16 pattern[REGMAP_TEST_BUF_SZ];
u16 *buffer;
struct udevice *dev;
@@ -311,7 +310,7 @@ static int dm_test_devm_regmap(struct unit_test_state *uts)
ut_assertok(regmap_write(priv->cfg_regmap, i, pattern[i]));
}
for (i = 0; i < REGMAP_TEST_BUF_SZ; i++) {
- ut_assertok(regmap_read(priv->cfg_regmap, i, valp));
+ ut_assertok(regmap_read(priv->cfg_regmap, i, &val));
ut_asserteq(val, buffer[i]);
ut_asserteq(val, pattern[i]);
}
@@ -319,9 +318,9 @@ static int dm_test_devm_regmap(struct unit_test_state *uts)
ut_asserteq(-ERANGE, regmap_write(priv->cfg_regmap, REGMAP_TEST_BUF_SZ,
val));
ut_asserteq(-ERANGE, regmap_read(priv->cfg_regmap, REGMAP_TEST_BUF_SZ,
- valp));
+ &val));
ut_asserteq(-ERANGE, regmap_write(priv->cfg_regmap, -1, val));
- ut_asserteq(-ERANGE, regmap_read(priv->cfg_regmap, -1, valp));
+ ut_asserteq(-ERANGE, regmap_read(priv->cfg_regmap, -1, &val));
return 0;
}
--
2.35.1.1094.g7c7d902a7c-goog
next prev parent reply other threads:[~2022-04-03 10:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-03 10:39 [PATCH 0/8] Fix misc ASAN reports Andrew Scull
2022-04-03 10:39 ` [PATCH 1/8] doc: Correct position of gdb '--args' parameter Andrew Scull
2022-04-11 18:35 ` Simon Glass
2022-04-29 18:03 ` Tom Rini
2022-04-03 10:39 ` [PATCH 2/8] acpi: Fix buffer overflow in do_acpi_dump() Andrew Scull
2022-04-11 18:35 ` Simon Glass
2022-04-29 18:03 ` Tom Rini
2022-04-03 10:39 ` [PATCH 3/8] x86: sandbox: Add missing PCI bar to barinfo Andrew Scull
2022-04-11 18:35 ` Simon Glass
2022-04-29 18:03 ` Tom Rini
2022-04-03 10:39 ` [PATCH 4/8] usb: sandbox: Check for string end in copy_to_unicode() Andrew Scull
2022-04-11 18:35 ` Simon Glass
2022-04-29 18:03 ` Tom Rini
2022-04-03 10:39 ` [PATCH 5/8] usb: sandbox: Bounds check read from buffer Andrew Scull
2022-04-11 18:35 ` Simon Glass
2022-04-29 18:03 ` Tom Rini
2022-04-03 10:39 ` [PATCH 6/8] sound: Fix buffer overflow in square wave generation Andrew Scull
2022-04-11 18:35 ` Simon Glass
2022-04-29 18:03 ` Tom Rini
2022-04-03 10:39 ` Andrew Scull [this message]
2022-04-11 18:35 ` [PATCH 7/8] test: Fix pointer overrun in dm_test_devm_regmap() Simon Glass
2022-04-29 18:03 ` Tom Rini
2022-04-03 10:39 ` [PATCH 8/8] test: dm: devres: Remove use-after-free Andrew Scull
2022-04-11 18:35 ` Simon Glass
2022-04-29 18:03 ` Tom Rini
2022-04-06 18:31 ` [PATCH 0/8] Fix misc ASAN reports Sean Anderson
2022-04-07 6:41 ` Andrew Scull
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=20220403103915.3338027-8-ascull@google.com \
--to=ascull@google.com \
--cc=jjhiblot@ti.com \
--cc=p.yadav@ti.com \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/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