* [PATCH 1/1] test: NULL dereference in test-uclass
@ 2021-06-03 20:08 Heinrich Schuchardt
2021-07-04 19:24 ` Simon Glass
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2021-06-03 20:08 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot, Heinrich Schuchardt
If a test-uclass device is probed outside a test, uts is not defined.
Avoid a NULL dereference in this case.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
test/dm/test-uclass.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c
index 067701734a..d2d1e0f190 100644
--- a/test/dm/test-uclass.c
+++ b/test/dm/test-uclass.c
@@ -32,6 +32,9 @@ static int test_post_bind(struct udevice *dev)
struct unit_test_state *uts = test_get_state();
struct dm_test_perdev_uc_pdata *uc_pdata;
+ if (!uts)
+ return 0;
+
dm_testdrv_op_count[DM_TEST_OP_POST_BIND]++;
ut_assert(!device_active(dev));
@@ -57,6 +60,9 @@ static int test_pre_probe(struct udevice *dev)
test-uclass.cstruct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev);
struct unit_test_state *uts = test_get_state();
+ if (!uts)
+ return 0;
+
dm_testdrv_op_count[DM_TEST_OP_PRE_PROBE]++;
ut_assert(priv);
ut_assert(device_active(dev));
@@ -70,6 +76,9 @@ static int test_post_probe(struct udevice *dev)
struct udevice *prev = list_entry(dev->uclass_node.prev,
struct udevice, uclass_node);
+ if (!uts)
+ return 0;
+
struct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev);
struct uclass *uc = dev->uclass;
@@ -103,6 +112,9 @@ static int test_init(struct uclass *uc)
{
struct unit_test_state *uts = test_get_state();
+ if (!uts)
+ return 0;
+
dm_testdrv_op_count[DM_TEST_OP_INIT]++;
ut_assert(uclass_get_priv(uc));
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] test: NULL dereference in test-uclass
2021-06-03 20:08 [PATCH 1/1] test: NULL dereference in test-uclass Heinrich Schuchardt
@ 2021-07-04 19:24 ` Simon Glass
0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2021-07-04 19:24 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: U-Boot Mailing List
Hi Heinrich,
On Thu, 3 Jun 2021 at 14:08, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> If a test-uclass device is probed outside a test, uts is not defined.
> Avoid a NULL dereference in this case.
I am missing the motivation for this patch. In what situation does this occur?
Regards,
Simon
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> test/dm/test-uclass.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-04 19:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 20:08 [PATCH 1/1] test: NULL dereference in test-uclass Heinrich Schuchardt
2021-07-04 19:24 ` Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.