From: Heinrich Schuchardt Date: Mon, 1 Feb 2021 02:01:54 +0000 (+0100) Subject: firmware: smci: possible NULL dereference X-Git-Url: http://git.dujemihanovic.xyz/%22/img/sics.gif/%22/static/git-favicon.png?a=commitdiff_plain;h=6f5edbaf938952e4a9860727c633dcaa36caf699;p=u-boot.git firmware: smci: possible NULL dereference 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 Reviewed-by: Simon Glass --- diff --git a/drivers/firmware/scmi/sandbox-scmi_devices.c b/drivers/firmware/scmi/sandbox-scmi_devices.c index 414da6f4df..1a6fafbf53 100644 --- a/drivers/firmware/scmi/sandbox-scmi_devices.c +++ b/drivers/firmware/scmi/sandbox-scmi_devices.c @@ -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);