[PATCH 1/1] test/dm: check if devices exist

Simon Glass sjg at chromium.org
Sun Jul 26 16:54:12 CEST 2020


Hi,

On Fri, 17 Jul 2020 at 06:41, Philippe REYNES
<philippe.reynes at softathome.com> wrote:
>
> Hi Heinrich
>
> > Running 'ut dm' on the sandbox without -D or -d results in segmentation
> > faults due to NULL pointer dereferences.
> >
> > Check that device pointers are non-NULL before using them.
> >
> > Use ut_assertnonnull() for pointers instead of ut_assert().
>
> Tested-by: Philippe Reynes <philippe.reynes at softathome.com>
>
> > Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> > ---
> > test/dm/acpi.c | 3 +++
> > test/dm/core.c | 10 +++++-----
> > test/dm/devres.c | 1 +
> > test/dm/test-fdt.c | 2 ++
> > test/dm/virtio.c | 7 +++++++
> > 5 files changed, 18 insertions(+), 5 deletions(-)
> >
> > diff --git a/test/dm/acpi.c b/test/dm/acpi.c
> > index 4c46dd83a6..ece7993cf3 100644
> > --- a/test/dm/acpi.c
> > +++ b/test/dm/acpi.c
> > @@ -96,7 +96,10 @@ DM_TEST(dm_test_acpi_get_table_revision,
> > static int dm_test_acpi_create_dmar(struct unit_test_state *uts)
> > {
> > struct acpi_dmar dmar;
> > + struct udevice *cpu;
> >
> > + ut_assertok(uclass_first_device(UCLASS_CPU, &cpu));
> > + ut_assertnonnull(cpu);

Here the fix should be in acpi_create_dmar() - calling
uclass_first_device_err().

> > ut_assertok(acpi_create_dmar(&dmar, DMAR_INTR_REMAP));
> > ut_asserteq(DMAR_INTR_REMAP, dmar.flags);
> > ut_asserteq(32 - 1, dmar.host_address_width);

[...]

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list