]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
firmware: smci: possible NULL dereference
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 1 Feb 2021 02:01:54 +0000 (03:01 +0100)
committerSimon Glass <sjg@chromium.org>
Wed, 3 Feb 2021 10:38:41 +0000 (03:38 -0700)
sandbox_scmi_devices_ctx() may return NULL. We should not dereference this
value in sandbox_scmi_devices_remove().

The problem was indicated by 'gcc-11 -fanalyzer'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/firmware/scmi/sandbox-scmi_devices.c

index 414da6f4df1611d73b16797aac058450653f0ded..1a6fafbf531bb843088b76f3c1315b029dd13f82 100644 (file)
@@ -50,6 +50,9 @@ static int sandbox_scmi_devices_remove(struct udevice *dev)
        int ret = 0;
        size_t n;
 
+       if (!devices)
+               return 0;
+
        for (n = 0; n < SCMI_TEST_DEVICES_RD_COUNT; n++) {
                int ret2 = reset_free(devices->reset + n);