src/security: Use "if (!ptr)" in preference to "if (ptr == NULL)"
Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Change-Id: I3def65c016015d8213824e6b8561d8a67b6d5cf0 Reviewed-on: https://review.coreboot.org/c/coreboot/+/67579 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
This commit is contained in:
parent
a6b41f2fd0
commit
aebccac7e1
|
@ -481,7 +481,7 @@ int add_pi_resource(STM_RSC *resource_list, uint32_t num_entries)
|
||||||
if (resource_size == 0)
|
if (resource_size == 0)
|
||||||
return -1; // INVALID_PARAMETER;
|
return -1; // INVALID_PARAMETER;
|
||||||
|
|
||||||
if (m_stm_resources_ptr == NULL) {
|
if (!m_stm_resources_ptr) {
|
||||||
|
|
||||||
// Copy EndResource for initialization
|
// Copy EndResource for initialization
|
||||||
m_stm_resources_ptr = stm_resource_heap;
|
m_stm_resources_ptr = stm_resource_heap;
|
||||||
|
@ -522,7 +522,7 @@ int add_pi_resource(STM_RSC *resource_list, uint32_t num_entries)
|
||||||
*/
|
*/
|
||||||
int32_t delete_pi_resource(STM_RSC *resource_list, uint32_t num_entries)
|
int32_t delete_pi_resource(STM_RSC *resource_list, uint32_t num_entries)
|
||||||
{
|
{
|
||||||
if (resource_list != NULL) {
|
if (resource_list) {
|
||||||
// ASSERT (false);
|
// ASSERT (false);
|
||||||
return -1; // UNSUPPORTED;
|
return -1; // UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ static uint32_t tlcl_send_startup(TPM_SU type)
|
||||||
response = tpm_process_command(TPM2_Startup, &startup);
|
response = tpm_process_command(TPM2_Startup, &startup);
|
||||||
|
|
||||||
/* IO error, tpm2_response pointer is empty. */
|
/* IO error, tpm2_response pointer is empty. */
|
||||||
if (response == NULL) {
|
if (!response) {
|
||||||
printk(BIOS_ERR, "%s: TPM communication error\n", __func__);
|
printk(BIOS_ERR, "%s: TPM communication error\n", __func__);
|
||||||
return TPM_E_IOERROR;
|
return TPM_E_IOERROR;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ static uint32_t tlcl_send_shutdown(TPM_SU type)
|
||||||
response = tpm_process_command(TPM2_Shutdown, &shutdown);
|
response = tpm_process_command(TPM2_Shutdown, &shutdown);
|
||||||
|
|
||||||
/* IO error, tpm2_response pointer is empty. */
|
/* IO error, tpm2_response pointer is empty. */
|
||||||
if (response == NULL) {
|
if (!response) {
|
||||||
printk(BIOS_ERR, "%s: TPM communication error\n", __func__);
|
printk(BIOS_ERR, "%s: TPM communication error\n", __func__);
|
||||||
return TPM_E_IOERROR;
|
return TPM_E_IOERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,7 +517,7 @@ static int unmarshal_TPM2B_MAX_NV_BUFFER(struct ibuf *ib,
|
||||||
|
|
||||||
nv_buffer->t.buffer = ibuf_oob_drain(ib, nv_buffer->t.size);
|
nv_buffer->t.buffer = ibuf_oob_drain(ib, nv_buffer->t.size);
|
||||||
|
|
||||||
if (nv_buffer->t.buffer == NULL) {
|
if (!nv_buffer->t.buffer) {
|
||||||
printk(BIOS_ERR, "%s:%d - "
|
printk(BIOS_ERR, "%s:%d - "
|
||||||
"size mismatch: expected %d, remaining %zd\n",
|
"size mismatch: expected %d, remaining %zd\n",
|
||||||
__func__, __LINE__, nv_buffer->t.size,
|
__func__, __LINE__, nv_buffer->t.size,
|
||||||
|
|
|
@ -18,7 +18,7 @@ uint32_t tlcl_cr50_enable_nvcommits(void)
|
||||||
|
|
||||||
response = tpm_process_command(TPM2_CR50_VENDOR_COMMAND, &sub_command);
|
response = tpm_process_command(TPM2_CR50_VENDOR_COMMAND, &sub_command);
|
||||||
|
|
||||||
if (response == NULL || (response && response->hdr.tpm_code)) {
|
if (!response || (response && response->hdr.tpm_code)) {
|
||||||
if (response)
|
if (response)
|
||||||
printk(BIOS_INFO, "%s: failed %x\n", __func__,
|
printk(BIOS_INFO, "%s: failed %x\n", __func__,
|
||||||
response->hdr.tpm_code);
|
response->hdr.tpm_code);
|
||||||
|
|
|
@ -17,10 +17,10 @@ static void *vboot_get_workbuf(void)
|
||||||
if (cbmem_possibly_online())
|
if (cbmem_possibly_online())
|
||||||
wb = cbmem_find(CBMEM_ID_VBOOT_WORKBUF);
|
wb = cbmem_find(CBMEM_ID_VBOOT_WORKBUF);
|
||||||
|
|
||||||
if (wb == NULL && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE) && preram_symbols_available())
|
if (!wb && !CONFIG(VBOOT_STARTS_IN_ROMSTAGE) && preram_symbols_available())
|
||||||
wb = _vboot2_work;
|
wb = _vboot2_work;
|
||||||
|
|
||||||
assert(wb != NULL);
|
assert(wb);
|
||||||
|
|
||||||
return wb;
|
return wb;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ static void vboot_setup_cbmem(int unused)
|
||||||
vb2_error_t rv;
|
vb2_error_t rv;
|
||||||
const size_t cbmem_size = VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE;
|
const size_t cbmem_size = VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE;
|
||||||
void *wb_cbmem = cbmem_add(CBMEM_ID_VBOOT_WORKBUF, cbmem_size);
|
void *wb_cbmem = cbmem_add(CBMEM_ID_VBOOT_WORKBUF, cbmem_size);
|
||||||
assert(wb_cbmem != NULL);
|
assert(wb_cbmem);
|
||||||
/*
|
/*
|
||||||
* On platforms where VBOOT_STARTS_BEFORE_BOOTBLOCK, the verification
|
* On platforms where VBOOT_STARTS_BEFORE_BOOTBLOCK, the verification
|
||||||
* occurs before the main processor starts running. The vboot data-
|
* occurs before the main processor starts running. The vboot data-
|
||||||
|
|
|
@ -383,7 +383,7 @@ static vb2_error_t ec_get_expected_hash(enum vb2_firmware_selection select,
|
||||||
/* vboot has no API to return this memory, so must permanently leak a mapping here. */
|
/* vboot has no API to return this memory, so must permanently leak a mapping here. */
|
||||||
const uint8_t *file = cbfs_map(filename, &size);
|
const uint8_t *file = cbfs_map(filename, &size);
|
||||||
|
|
||||||
if (file == NULL)
|
if (!file)
|
||||||
return VB2_ERROR_UNKNOWN;
|
return VB2_ERROR_UNKNOWN;
|
||||||
|
|
||||||
*hash = file;
|
*hash = file;
|
||||||
|
|
Loading…
Reference in New Issue