Fix null pointer dereferences
This CL fixes two null pointer dereferences:
- The first occurs in memory_spd_dump_cmd, which calls new_spd_device
without checking if intf->cb->memory->spd is non-null and
new_spd_device directly calls that function.
- The second happens because the read_ram_code function in
platform/google/gru/memory.c caches whether or not it has already run
but not what the return code for the previous run was. This means
that if an error occurred during the first call, the global variables
would not be set but subsequent calls would return success, which
would cause the calling code to dereference a null pointer if it
attempted to access gru_mem_info.
TEST=run 'mosys memory spd dump 0' and 'mosys memory spd print all' and
see that they no longer crash.
Signed-off-by: Chirantan Ekbote <firstname.lastname@example.org>
Reviewed-by: David Hendricks <email@example.com>
2 files changed